2 ms·
How will there never be undefined behaviour?
by andrepd 5y ago
How will there never be undefined behaviour?
- jandrewrogers 5y agoI meant in the sense that unsigned integers have C-specified defined behaviors for conditions like overflow that are undefined for signed integers. That said, if you bothering to create these integers types (e.g. the common MAX sentinel idiom), their behavior is often fully defined. If you go crazy with metaprogramming, type inference, etc in recent C++, you can often verify at compile-time that these conditions will not occur across arithmetic operations, though this is a lot less trivial.