title: c struct with zero sized array members
body: <p>I encountered some syntax in an Android open source code that I can't understand. There is a struct that looks something like this:</p>
  
  <pre><code>    struct __attribute__((packed)) A
  {
   uint8_t bla;
   uint8_t bla2;
   uint8_t someFixedSizeArr[20];
   uint8_t padded[0]; //Marks offset to padded data
   uint8_t someFixedSizeArr2[30];
   uint8_t transformed[0]; //Marks offset to transformed data
   int32_t length;
   uint8_t result[100];
  };
  </code></pre>
  
  <p>I don't understand what padded and transformed are and how they work. Later on, a type B's ctor (which wraps A) doesn't touch them, so they are un-initialized when B is created, yet later on they are referenced as such:</p>
  
  <pre><code>memmove(&amp;A.padded[padLength], &amp;A.result[A.length], 30);
  </code></pre>
  
  <p>And also:</p>
  
  <pre><code>someFunc(A.transformed, 30, A.someFixedSizeArr);
  </code></pre>
  
  <p>So what happens here, memory wise, with these zero sized arrays? Note that I read about zero sized arrays but this doesn't seem to match what I read, because there it stated that the array must be the last field of a struct, which is not the case here.</p>
  
  <p>Thank you</p>