This is a good example, and I think shows persuasively that it&#x27;s good for a compiler to make logical assumptions about inputs when inlining code.  But I think this is different than making optimizations by presuming the absence of undefined behavior when compiling the function itself.<p>Consider a programmer who feels it&#x27;s clearer to dereference a and b once, rather than writing using * a and * b in the complicated math after the preliminary checks.  And because they don&#x27;t want to rely on C99 or distract by opening  a new block, they put the conversion at the top of the function.  Oh, and the new guy decided to add the &quot;missile launch&quot; code here.<p><pre><code>    int computation(int *ptr_a, int *ptr_b) {
        int val_a = *a, val_b = *b;
        if(ptr_a == NULL &amp;&amp; ptr_b == NULL) return 0;
        if(ptr_a == NULL) return val_b;
        if(ptr_b == NULL) return val_a;
        launch_missiles(); &#x2F;* OK to put this here? *&#x2F;
        return ...something with val_a and val_b...;
    }

</code></pre>
I think there is a reasonable argument that there is a difference between optimizing when a code path can be shown to never occur because of constrained inputs, and optimizing because behavior supposedly can be inferred from the absence of undefined behavior.<p>I&#x27;m fine with a literalist compiler that produces code that crashes when it immediately tries to dereference a NULL pointer, with one that produces code that does the safety checks but defers the load, but even if allowed by the spec[1] I don&#x27;t think it&#x27;s good behavior for a compiler to silently omit the safety checks and launch the missiles when passed a NULL.<p>[1] Is this undefined behavior according to the spec? I consider myself an expert C programmer, and I think it&#x27;s undefined in C99, but I wouldn&#x27;t bet that I&#x27;ve correctly understood the issues for the other dialects of C, muchless C++. Is a conforming compiler &quot;allowed&quot; to skip the safety checks and launch the missiles?  I don&#x27;t know, and thus defensively wouldn&#x27;t write the code like this, but it would be nice to think that long-standing mission-critical code written by others won&#x27;t suddenly stop working with a new release of the optimizing compiler.