| ▲ | fluoridation 3 hours ago | |
Some behaviors are left unspecified instead of undefined, which allows each implementation to choose whatever behavior is convenient, such as, as you put it, whatever the hardware does. IIRC this is the case in C for modulo with both negative operands. I would imagine that the standard writers choose one or the other depending on whether the behavior is useful for optimizations. There's also the matter that if a behavior is currently undefined, it's easy to later on make it unspecified or specified, while if a behavior is unspecified it's more difficult to make it undefined, because you don't know how much code is depending on that behavior. | ||
| ▲ | zephen 44 minutes ago | parent [-] | |
But even integer overflow is undefined. It's practically impossible to find a program without UB. | ||