title: Aggregate Member Initialization in C++14
body: <p>Having this structure:</p>
  
  <pre><code>struct A {
      struct B {
          int a = 21;
          int b;
          int c = 22;
          int d;
          int e = 23;
      };
      B b1  = { 11, 12 };
      B b2  = { 11, 12, 13 };
      int x;
  };
  </code></pre>
  
  <p>And declaring:</p>
  
  <pre><code>A a = { { 1, 2, 3, 4 }, { 1 }, 5 };
  </code></pre>
  
  <p>According to both Clang (3.8.0) and GCC (5.4.0), these are the values of the 8 possible combinations (a.b1.e and a.b2.a are repeated cases), regarding where the initial value is taken from (or not), :</p>
  
  <pre><code>a.b1.a = 1   // 111
  a.b1.b = 2   // 110
  a.b1.c = 3   // 101
  a.b1.d = 4   // 100
  a.b2.b = 0   // 010    // Why not 12 instead of  0? -&gt; Explained in N3605
  a.b2.c = 22  // 011    // Why not  0 instead of 22 ?  Why not 13 ?
  a.b2.d = 0   // 000
  a.b2.e = 23  // 001    // Why not  0 instead of 23 ?
  </code></pre>
  
  <p>Taking into account the example in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html?cm_mc_uid=02271754051914834448186&amp;cm_mc_sid_50200000=1484048606" rel="nofollow noreferrer">N3605</a> and the C++14 Standard (ISO/IEC 14882:2014), Section 8.5.1, Paragraph 7:</p>
  
  <blockquote>
    <p>If there are fewer <em>initializer-clauses</em> in the list than there are members in the aggregate, then each member not explicitly initialized shall be initialized from its <em>brace-or-equal-initializer</em> or, if there is no <em>brace-or-equal-initializer</em>, from an empty initializer list (8.5.4).</p>
  </blockquote>
  
  <p>I assume case 010 is correct. Then, why cases 011 (a.b2.c) and 001 (a.b2.e) are not also equal to zero? Case 010 is zero because a.b2 "does have an initializer", therefore "the non-static data member initializer is ignored" (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html?cm_mc_uid=02271754051914834448186&amp;cm_mc_sid_50200000=1484048606" rel="nofollow noreferrer">N3605</a> again). Why the default member initializers are not ignored as well? </p>
  
  <p>In fact, reading the C++14 Standard quote it would make more sense to me that case 010 would be 12 (it is zero) and cases 011 and 001 would be zero (as they actually are). So what I don't understand is why a.b2 is sometimes considered to "have an initializer" and other times it is not.</p>