I thought it would be interesting to see how some different compilers actually behave here.   This was my test program:<p><pre><code>  nate@haswell:~&#x2F;tmp$ cat deref.c
  &#x2F;* gcc -fno-inline -O3 -g -Wall deref.c -o deref *&#x2F;
  &#x2F;* (or as desired to show particular outcome) *&#x2F;

  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;

  void deref_and_print(int *ptr) {
    int i = *ptr;  &#x2F;* undefined behavior if ptr is NULL *&#x2F;
    if (ptr == NULL) printf(&quot;NULL\n&quot;);
    else printf(&quot;%d\n&quot;, i);
  }

  int main(int argc, char **argv) {
    int *ptr = NULL;
    if (argc &lt;= 1) {
      printf(&quot;Usage: %s [arg]\n&quot;, argv[0]);
      printf(&quot; Demonstrates undefined behavior if &#x27;arg&#x27;&quot;);
      printf(&quot; is not a positive integer\n&quot;);
      exit(1);
    }
    int i = atoi(argv[1]);
    if (i &gt; 0) ptr = &amp;i;
    deref_and_print(ptr);
    exit(0);
  }
</code></pre>
As you guessed, icc, gcc, and clang all crash with a segfault for &#x27;deref 0&#x27; when compiled with -O0.  But more interestingly, when compiled with -O1, -O2, or -O3, clang prints &quot;NULL&quot;, while icc and gcc continue to crash.