<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 989</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="989"></A><H4>989.
  
Misplaced list-initialization example
</H4>
<B>Section: </B>9.5.5&#160; [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD2
 &#160;&#160;&#160;

 <B>Submitter: </B>Daniel Kr&#252;gler
 &#160;&#160;&#160;

 <B>Date: </B>20 October, 2009<BR>


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



<P>The final set of declarations in the example following 9.5.5 [<A href="https://wg21.link/dcl.init.list#3.3">dcl.init.list</A>] bullet 3.3 is:</P>

<PRE>
    struct S2 {
      int m1;
      double m2,m3;
    };
    S2 s21 = { 1, 2, 3.0 };    // OK
    S2 s22 { 1.0, 2, 3 };      // error: narrowing
    S2 s23 {};                 // OK: default to 0,0,0
</PRE>

<P>However, <TT>S2</TT> is an aggregate.  Aggregates are handled
in bullet 1, while bullet 3 deals with classes with constructors.
This part of the example should be moved to the first bullet.</P>

<P><B>Proposed resolution (October, 2009):</B></P>

<P>Move the <TT>S2</TT> example from bullet 3 to bullet 1 in
9.5.5 [<A href="https://wg21.link/dcl.init.list#3">dcl.init.list</A>] paragraph 3:</P>

<UL>
<LI>
<P>If <TT>T</TT> is an aggregate, aggregate initialization is
performed (9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>]).</P>

<P>[<I>Example:</I>
</P>

<PRE>
  double ad[] = { 1, 2.0 };   //<SPAN CLASS="cmnt"> OK</SPAN>
  int ai[] = { 1, 2.0 };      //<SPAN CLASS="cmnt"> error: narrowing</SPAN>
<INS>
  struct S2 {
    int m1;
    double m2,m3;
  };
  S2 s21 = { 1, 2, 3.0 };     //<SPAN CLASS="cmnt"> OK</SPAN>
  S2 s22 { 1.0, 2, 3 };       //<SPAN CLASS="cmnt"> error: narrowing</SPAN>
  S2 s23 {};                  //<SPAN CLASS="cmnt"> OK: default to 0,0,0</SPAN></INS>
</PRE>

<P>&#8212;<I>end example</I>]</P>

</LI>

<LI><P>Otherwise, if <TT>T</TT> is a specialization...</P></LI>

<LI>
<P>Otherwise, if T is a class type...</P>

<P>[<I>Example:</I>
</P>

<PRE>
  ...
  S s3 { };                   //<SPAN CLASS="cmnt"> OK: invoke #2</SPAN>
<DEL>
  struct S2 {
    int m1;
    double m2,m3;
  };
  S2 s21 = { 1, 2, 3.0 };     //<SPAN CLASS="cmnt"> OK</SPAN>
  S2 s22 { 1.0, 2, 3 };       //<SPAN CLASS="cmnt"> error: narrowing</SPAN>
  S2 s23 {};                  //<SPAN CLASS="cmnt"> OK: default to 0,0,0</SPAN></DEL>
</PRE>

<P>&#8212;<I>end example</I>]</P>

</LI>

<LI><P>...</P></LI>

</UL>

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