With Undefined Behavior, Anything Is Possible
Nice article! From the outside, it seems so obvious that the fix for C is to reduce the scope of undefined behavior, either by simply defining it or making it &quot;implementation defined&quot;.  But it seems equally obvious that this is not going to happen.<p><i>The standards committee invented the concept of “undefined behavior” to capture this range of behavior. Essentially, it’s a license for the implementation to do anything it wants. And that’s reasonable; it’s hard to imagine nailing down the behavior any further without compromising performance or the fundamental nature of the problem. But given this hammer, the committee applied it far more broadly.</i><p><i>However, compiler authors got bolder over time, feeling that everything allowed in the standard was fair game, at the same time getting more sophisticated in what optimizations could be done with stronger assumptions.</i><p>Are &quot;compiler authors&quot; and the &quot;standards committee&quot; really two distinct groups?  I&#x27;ve presumed that the expansion of &quot;undefined behavior&quot; in C is an example of &quot;regulatory capture&quot;.  That is, the specifications of the language are being decided by those who see &quot;undefined&quot; as yet another opportunity for optimization, as opposed to the users of compilers who tend to be more worried about broken programs.