title: non-static initialization of a flexible array member
body: <p>I'm trying to populate a struct member with an array created at runtime and get the following error:</p>
  
  <pre><code>error: non-static initialization of a flexible array member
               .entries = entries
                          ^
  </code></pre>
  
  <p>I have isolated the problem and reproduced it in simpler code to make it clearer:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  
  typedef struct entry {
      char *title;
      int id;
  } Entry;
  
  typedef struct collection {
      size_t size;
      Entry entries[];
  } Collection;
  
  // This function signature may not be changed
  void populate(int n, Collection *result){
  
      Entry entries[n];
  
      for (int i = 0; i &lt; n; ++i) {
          Entry entry = {
                  .title = "Title",
                  .id = i
          };
  
          entries[i] = entry;
      }
  
      Collection collection = {
              .size = n,
              .entries = entries
      };
  
      result = &amp;collection;
  }
  </code></pre>
  
  <p>How can I fix this?</p>