4 ms·
> does what you see is undefined behavior Just to be clear, undefined behavior means the standard allows implementations to do what they they feel is the right
by geezerjay 8y ago
> does what you see is undefined behavior
Just to be clear, undefined behavior means the standard allows implementations to do what they they feel is the right thing to do under that scenario, and the outcome will still comply with the standard.
- berti 8y agoNo, that's implementation defined behaviour.
- deleted 8y ago[deleted]
- nothrabannosir 8y agoUndefined behaviour, in reality, means: the compiler will assume that it doesn’t happen, so whatever code path leading up to it can also (by definition) not happen and be eliminated. E.g. signed integer overflow “cannot happen” so you never need to emit code checking for it or dealing with it. That’s the real world implication of undefined behaviour.
- MauranKilom 8y agoUndefined behavior is "literally anything can happen". So yes, implementations doing "what they feel is the right thing to do" is one possible result of UB (as in this case). It could also emit an rm -rf / call and it would still comply with the standard...