title: Is the "struct hack" technically undefined behavior?
body: <p>What I am asking about is the well known "last member of a struct has variable length" trick. It goes something like this:</p>
  
  <pre><code>struct T {
      int len;
      char s[1];
  };
  
  struct T *p = malloc(sizeof(struct T) + 100);
  p-&gt;len = 100;
  strcpy(p-&gt;s, "hello world");
  </code></pre>
  
  <p>Because of the way that the struct is laid out in memory, we are able to overlay the struct over a larger than necessary block and treat the last member as if it were larger than the <code>1 char</code> specified.</p>
  
  <p>So the question is: <strong>Is this technique technically undefined behavior?</strong>. I would expect that it is, but was curious what the standard says about this.</p>
  
  <p>PS: I am aware of the C99 approach to this, I would like the answers to stick specifically to the version of the trick as listed above.</p>