<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2713</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="2713"></A><H4>2713.
  
Initialization of reference-to-aggregate from designated initializer list
</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>CD7
 &#160;&#160;&#160;

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2023-04-06<BR>


<P>[Accepted as a DR at the June, 2023 meeting.]</P>



<P>Aggregates can be initialized by a designated initializer list, but
references to aggregates cannot, although list-initialization of such
with a regular <I>braced-init-list</I> is fine.</P>

<P>Subclause 9.5.5 [<A href="https://wg21.link/dcl.init.list#3">dcl.init.list</A>] paragraph 3 specifies:</P>

<BLOCKQUOTE>

List-initialization of an object or reference of type T is defined as
follows:

<UL>
<LI>If the <I>braced-init-list</I> contains
a <I>designated-initializer-list</I>, T shall be an aggregate class. ...</LI>

<LI>...</LI>

<LI>Otherwise, if T is a reference type, a prvalue is generated. The
prvalue initializes its result object by copy-list-initialization from
the initializer list. The prvalue is then used to direct-initialize
the reference.  The type of the prvalue is the type referenced by T,
unless ...</LI>

<LI>...</LI>
</UL>

</BLOCKQUOTE>

<P>Subclause 12.2.4.2.6 [<A href="https://wg21.link/over.ics.list#2">over.ics.list</A>] paragraph 2 specifies:</P>

<BLOCKQUOTE>

If the initializer list is a <I>designated-initializer-list</I>, a
conversion is only possible if the parameter has an aggregate type
that can be initialized from the initializer list according to the
rules for aggregate initialization (9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>]), in
which case the implicit conversion sequence is a user-defined
conversion sequence whose second standard conversion sequence is an
identity conversion.

</BLOCKQUOTE>

<P><B>Proposed resolution (approved by CWG 2023-04-28):</B></P>

<OL>
<LI>
<P>Change in 9.5.5 [<A href="https://wg21.link/dcl.init.list#3.1">dcl.init.list</A>] bullet 3.1 as follows:</P>

<BLOCKQUOTE>

<UL>
<LI>If the <I>braced-init-list</I> contains
a <I>designated-initializer-list</I> <INS>and <TT>T</TT> is not a
reference type</INS>, T shall be an aggregate class. ...</LI>

<LI>...</LI>
</UL>

</BLOCKQUOTE>
</LI>


<LI>
<P>Change in 9.5.5 [<A href="https://wg21.link/dcl.init.list#3.9">dcl.init.list</A>] bullet 3.9 as follows:</P>

<BLOCKQUOTE>

Otherwise, if the initializer list <INS>is not
a <I>designated-initializer-list</I> and</INS> has a single element of
type E and ...

</BLOCKQUOTE>

</LI>

<LI>
<P>Change in 9.5.5 [<A href="https://wg21.link/dcl.init.list#3.10">dcl.init.list</A>] bullet 3.10 as follows:</P>

<BLOCKQUOTE>
[ Example:
<PRE>
  ...
  const B&amp; b2{a};  //<SPAN CLASS="cmnt"> error: cannot copy-list-initialize B temporary from A</SPAN>
<INS>  struct C { int x; };
  C&amp;&amp; c = { .x = 1 };  //<SPAN CLASS="cmnt"> OK</SPAN></INS>
</PRE>
-- end example ]
</BLOCKQUOTE>

</LI>

<LI>
<P>Change in 12.2.4.2.6 [<A href="https://wg21.link/over.ics.list#2">over.ics.list</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

If the initializer list is a <I>designated-initializer-list</I>
<INS>and the parameter is not a reference</INS>, a conversion is only
possible if the parameter has an aggregate type that can be
initialized from the initializer list according to the rules for
aggregate initialization (9.5.2 [<A href="https://wg21.link/dcl.init.aggr">dcl.init.aggr</A>]), in which case
the implicit conversion sequence is a user-defined conversion sequence
whose second standard conversion sequence is an identity conversion.

</BLOCKQUOTE>
</LI>
</OL>

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