<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1030</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="1030"></A><H4>1030.
  
Evaluation order in <I>initializer-list</I>s used in aggregate initialization
</H4>
<B>Section: </B>9.5.2&#160; [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>Scott Meyers
 &#160;&#160;&#160;

 <B>Date: </B>2010-02-09<BR>


<P>[Voted into the WP at the March, 2011 meeting.]</P>



<P>The ordering imposed by 9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>] paragraph
17 applies only to &#8220;the full-expressions in an
<I>initializer-clause</I>&#8221; (i.e., what follows an
<TT>=</TT> in an aggregate initializer); this leaves unspecified
the order in which the expressions in an <I>initializer-list</I>
(the term used by the <I>braced-init-list</I> form of
initializer, with no <TT>=</TT>) are evaluated.</P>

<P><B>Notes from the November, 2010 meeting:</B></P>

<P>The CWG favored guaranteeing the order of evaluation of
<I>initializer-clause</I>s appearing in a <I>braced-init-list</I>,
regardless of whether the <I>braced-init-list</I> is an aggregate
initialization or constructor call.</P>

<P><B>Proposed resolution (January, 2011):</B></P>

<OL>
<LI><P>Delete 9.5.2 [<A href="https://wg21.link/dcl.init.aggr#17">dcl.init.aggr</A>] paragraph 17:</P></LI>

<BLOCKQUOTE>

<DEL>The full-expressions in an <I>initializer-clause</I> are
evaluated in the order in which they appear.</DEL>

</BLOCKQUOTE>

<LI><P>Insert the following as a new paragraph between paragraphs
3 and 4 of 9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>]</P></LI>

<BLOCKQUOTE>

<INS>Within the <I>initializer-list</I> of a <I>braced-init-list</I>,
the <I>initializer-clause</I>s, including any that result from pack
expansions (13.7.4 [<A href="https://wg21.link/temp.variadic">temp.variadic</A>]), are evaluated in the order
in which they appear. That is, every value computation and side effect
associated with a given <I>initializer-clause</I> is sequenced before
every value computation and side effect associated with any
<I>initializer-clause</I> that follows it in the comma-separated list
of the <I>initializer-list</I>. [<I>Note:</I> This evaluation ordering
holds regardless of the semantics of the initialization; for example,
it applies when the elements of the <I>initializer-list</I> are
interpreted as arguments of a constructor call, even though ordinarily
there are no sequencing constraints on the arguments of a call.
&#8212;<I>end note</I>]</INS>

</BLOCKQUOTE>

</OL>

<BR><BR>
</BODY>
</HTML>
