title: flexible array member in a nested struct
body: <p>Is it valid C code to have flexible array members inside nested structs? So is my sample code below guarenteed to work as expected with a sane compiler?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct d {
      char c;
      int ns[];
  };
  
  struct c {
      struct d d;
  };
  
  struct b {
      struct c c;
  };
  
  struct a {
      int n;
      struct b b;
  };
  
  int main() {
      const int n = 10;
      struct a *pa = malloc(sizeof(*pa) + n * sizeof(pa-&gt;b.c.d.ns[0]));
      pa-&gt;n = n;
      pa-&gt;b.c.d.c = 1;
      for (int i = 0; i &lt; n; ++i) {
          pa-&gt;b.c.d.ns[i] = i;
      }
      for (int i = 0; i &lt; n; ++i) {
          printf("%d\n", pa-&gt;b.c.d.ns[i] + pa-&gt;b.c.d.c);
      }
      free(pa);
  }
  </code></pre>