Undefined behavior in C is a reading error
Because there seems to be some confusion in this thread:<p>- &quot;Implementation-defined behavior&quot; means that the C standard specifies the allowable behaviors that a C implementation must choose from, and the implementation must document its particular choice.<p>- &quot;Unspecified behavior&quot; means that the C standard places no particular restrictions on the  behavior, but a C implementation must pick a behavior and document its choice.<p>- &quot;Undefined behavior&quot; means that C implementations are allowed to assume that the respective runtime condition does not ever occur, and for example can generate optimized code based on that assumption. In particular, it is free to <i>not</i> decide any behavior for the condition (let alone document it). As a consequence, if the runtime condition actually <i>does</i> occur, this can affect the behavior of <i>any</i> part of the program, even the behavior of code executed before the condition would occur. This is because from a false assumption the truth of <i>any</i> statement can be logically derived (principle of explosion [0]). And that is why the C standard does not restrict the behavior of the whole program if it contains undefined behavior.<p>[0] <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Principle_of_explosion" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Principle_of_explosion</a>