title: Is dereferencing null pointer valid in sizeof operation
body: <p>I've come across a snippet of code that to me should crash with a <em>segmentation fault</em>, and yet it works without a hitch.  The code in question plus relevant data structure is as follows (with associated comment found right above):</p>
  
  <pre><code>typedef struct {
    double length;
    unsigned char nPlaced;
    unsigned char path[0];
  }
  
  
  RouteDefinition* Alloc_RouteDefinition()
  {
    // NB: The +nBags*sizeof.. trick "expands" the path[0] array in RouteDefinition
    // to the path[nBags] array
    RouteDefinition *def = NULL;
    return (RouteDefinition*) malloc(sizeof(RouteDefinition) + nBags * sizeof(def-&gt;path[0]));
  }
  </code></pre>
  
  <p>Why does this work? I gather that the <em>sizeof</em> the <em>char</em>* will resolve to the size of the pointer on the given architecture, but shouldn't it crash and burn while dereferencing a <code>NULL</code>-pointer? </p>