Re:Undefined behavior in C is a reading error
by tsimionescu on Friday May 21, 2021 @07:44AM
(#27232806)
It implies it, but they are not equivalent. Basically the common interpretation of UB is sufficient, but not necessary, given the standard.
> undefined behavior: behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements.
With these optimisations, either:
1. The program contains no UB, the transformed code acts as expected, and the compilation is valid.
2. There's UB; the standard imposes no requirements on what behaviour that translates to; and so the transformed code is valid, regardless of what it does.