3 ms·
Actually, invoking undefined behavior anywhere in the code, even unreachable code, means the entire program is invalid. Including for all inputs. The reason it
by lawnchair_larry 10y ago
Actually, 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 10y 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.