title: Order of evaluation of elements in list-initialization
body: <p>In the <a href="https://stackoverflow.com/questions/14056000/how-to-avoid-undefined-execution-order-for-the-constructors-when-using-stdmake">other topic</a>, @Dietmar gave this solution:</p>
  
  <pre><code>template &lt;typename... T&gt;
  std::tuple&lt;T...&gt; parse(std::istream&amp; in) 
  {
      return std::tuple&lt;T...&gt;{ T(in)... };
  }
  </code></pre>
  
  <p>stating that,</p>
  
  <blockquote>
    <p>The use of brace initialization works because the <strong>order of evaluation of the arguments</strong> in a brace initializer list <strong>is the order in which they appear</strong>. (emphasize mine)</p>
  </blockquote>
  
  <p>The relevant text from the C++ Standard (n3485) is,</p>
  
  <blockquote>
    <p>Within the initializer-list of a braced-init-list, the initializer-clauses, including any that result from pack expansions (14.5.3), are evaluated in the order in which they appear. That is, every value computation and side effect associated with a given initializer-clause is sequenced before every value computation and side effect associated with any initializer-clause that follows it in the comma-separated list of the initializer-list. 
    [ Note: This evaluation ordering holds regardless of the semantics of the initialization; for example, it applies when the elements of the initializer-list are interpreted as arguments of a constructor call, even though ordinarily there are no sequencing constraints on the arguments of a call. —end note ]</p>
  </blockquote>
  
  <hr>
  
  <p>So I tried to test this with the following code:</p>
  
  <pre><code>template&lt;int N&gt;
  struct A 
  { 
      std::string data;
      A(std::istream &amp; stream) { stream &gt;&gt; data; }
      friend std::ostream&amp; operator&lt;&lt;(std::ostream &amp; out, A&lt;N&gt; const &amp; a) 
      {
          return out &lt;&lt; "A"&lt;&lt;N&lt;&lt;"::data = " &lt;&lt; a.data;
      }
  };
  typedef A&lt;1&gt; A1;
  typedef A&lt;2&gt; A2;
  
  template&lt;typename ...Args&gt;
  void test(std::istream &amp; stream)
  {
      std::tuple&lt;Args...&gt; args { Args(stream)... };
      std::cout &lt;&lt; std::get&lt;0&gt;(args) &lt;&lt; std::endl;
      std::cout &lt;&lt; std::get&lt;1&gt;(args) &lt;&lt; std::endl;
  }
  
  int main()
  {
      std::stringstream ss("A1 A2");
      test&lt;A1,A2&gt;(ss);
  }
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>A1::data = A1
  A2::data = A2
  </code></pre>
  
  <p>Actual Output:</p>
  
  <pre><code>A1::data = A2
  A2::data = A1
  </code></pre>
  
  <p>Did I do anything wrong in my test code? I changed my code to this:</p>
  
  <pre><code>std::stringstream ss("A1 A2");
  std::tuple&lt;A1,A2&gt; args{A1(ss), A2(ss)};
  std::cout &lt;&lt; std::get&lt;0&gt;(args) &lt;&lt; std::endl;
  std::cout &lt;&lt; std::get&lt;1&gt;(args) &lt;&lt; std::endl
  </code></pre>
  
  <p>Same output as before. I tested my code with <code>MinGW (GCC) 4.7.0</code> and <code>4.7.2</code>. Even ideone gives <a href="http://ideone.com/jPrpiR" rel="nofollow noreferrer">this output</a>.</p>
  
  <p>Is it a bug in the compiler?</p>