title: Why can this C code run correctly?
body: <p>The C code likes this:  </p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;unistd.h&gt; 
   #define DIM(a) (sizeof(a)/sizeof(a[0])) 
   struct obj
   {
       int a[1];
   };
   int main()
   {
       struct obj *p = NULL;
       printf("%d\n",DIM(p-&gt;a));
       return 0;
   }
  </code></pre>
  
  <p>This object pointer <code>p</code> is <code>NULL</code>, so, i think this <code>p-&gt;a</code> is illegal.
  But i have tested this code in Ubuntu14.04, it can execute correctly. So, I want to know why...</p>
  
  <hr>
  
  <p>Note: the original code had <code>int a[0]</code> above but I've changed that to <code>int a[1]</code> since everyone seems to be hung up on that rather than the <em>actual</em> question, which is:</p>
  
  <p><strong><em>Is the expression <code>sizeof(p-&gt;a)</code> valid when <code>p</code> is equal to <code>NULL</code>?</em></strong></p>