[EDIT: more clearly distinguished between undefined and unspecified behavior.]<p>&gt; Question: why can&#x27;t existing C compilers clearly indicate when they encounter undefined behavior?<p>Why can&#x27;t existing programs clearly indicate when they encounter unexpected input?<p>Not every instance of undefined behavior has explicit handling in a compiler; sometimes, undefined behavior occurs as part of the <i>implicit</i> functioning of the compiler implementation.  The compiler does not need to consider undefined behavior <i>at all</i>.  It doesn&#x27;t necessarily have an explicit case for &quot;undefined, choose a behavior&quot;; it can simply act as though undefined behavior does not exist, and have the behavior in that case depend on whatever the code written to handle defined behavior happens to do in the undefined case.<p>[EDIT: This example is unspecified behavior, not undefined behavior.  The example does still illustrate what I meant by behavior that arises out of the compiler implementation without explicit notice by the compiler.]<p>For instance, if you write f(g(), h()), C doesn&#x27;t specify whether g or h gets called first.  The compiler doesn&#x27;t explicitly parse that whole expression and internally note &quot;oh, you have unspecified behavior here, I&#x27;ll silently choose an interpretation and not tell you about it&quot;.  The compiler just parses the expression and breaks it down into sequential operations, implicitly choosing an interpretation based on its parsing, evaluation, and optimization.  The compiler might evaluate g() first because it parses left-to-right, or h() first because it parses right-to-left, or h() first because h() was an inline function and it expands those first...<p>A compiler explicitly designed to flag undefined behaviors would need to have additional logic to notice undefined behaviors; you couldn&#x27;t just take an existing compiler and find all the places where it <i>explicitly</i> notices undefined behavior and chooses a way to handle it.<p>Existing compilers have started to add warnings for cases where they explicitly <i>exploit</i> undefined behavior for optimization, such as assuming a lack of signed overflow, or assuming that you never dereference a NULL pointer.  But retrofitting a compiler to flag cases where it currently just doesn&#x27;t even consider the undefined behavior would require far more work.