3 ms·
It would be complying with the standard if it compiled the whole program into one single call to abort! And yet it didn't do that. I wonder why not.
by to3m 9y ago
It would be complying with the standard if it compiled the whole program into one single call to abort! And yet it didn't do that. I wonder why not.
- caf 9y agoThe code in question is not ill-defined over all inputs - it has well-defined behaviour as long as the offset in question doesn't exceed the size of the object that it is being used to address.
- lawnchair_larry 9y agoActually, invoking undefined behavior anywhere in the code, even unreachable code, means the entire program is invalid. Including for all inputs. The reason it doesn't simply abort is because compiler authors don't go out of their way to do extra work for no reason.
- zAy0LfpBZLC8mAC 9y ago> Actually, invoking undefined behavior anywhere in the code, even unreachable code, means the entire program is invalid. Erm ... nope. If code is unreachable, it can, by definition, not exhibit undefined behaviour. > The reason it doesn't simply abort is because compiler authors don't go out of their way to do extra work for no reason. Well, true, but the primary reason is that there are parts of the input domain for which the behaviour of the code is actually defined, and it's not defined to mean a call to abort(). The mere possibility to call some code at runtime with values for which the behaviour is undefined does not make the code's semantics completely undefined.