<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1095</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="1095"></A><H4>1095.
  
List-initialization of references
</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>C++11
 &#160;&#160;&#160;

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

 <B>Date: </B>2010-07-26<BR>


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3262.]</P>



<P>The current wording of the WP appears not to allow for list-initialization
of a reference like the following:</P>

<PRE>
    int i;
    int&amp; ir{i};
</PRE>

<P>First, 9.5 [<A href="https://wg21.link/dcl.init#16.1">dcl.init</A>] bullet 16.1 reads,</P>

<UL><LI><P>If the initializer is a braced-init-list, the
object is list-initialized (8.5.4).</P></LI></UL>

<P>A reference is not an object, so this does not appear to apply;
however, the second bullet sends reference initialization off to
9.5.4 [<A href="https://wg21.link/dcl.init.ref">dcl.init.ref</A>], which does not cover
<I>braced-init-list</I>s: paragraph 5 of that section deals only
with initilizer expressions, and a <I>braced-init-list</I> is not
an expression.</P>

<P>Assuming that the use of &#8220;object&#8221; in the first bullet
is just an oversight, 9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>] also does not
cover the case of a reference to a scalar type whose initalizer
is a <I>braced-init-list</I> with a single element.  Bullet 7 of
paragraph 3 reads,</P>

<UL><LI><P>Otherwise, if the initializer list has a single
element, the object is initialized from that
element</P></LI></UL>

<P> and would cover this case except that, again, a
reference is not an object.  As a result, such an
initialization would end up in the last bullet and
consequently be ill-formed.</P>

<P>Presumably all that is needed is to add &#8220;or
reference&#8221; to the appropriate bullets of 9.5 [<A href="https://wg21.link/dcl.init#16">dcl.init</A>] paragraph 16
and 9.5.5 [<A href="https://wg21.link/dcl.init.list#3">dcl.init.list</A>] paragraph 3.</P>

<P><B>Proposed resolution (November, 2010) [SUPERSEDED]:</B></P>

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

<UL><LI><P>If the initializer is a <I>braced-init-list</I>, the object
<INS>or reference</INS> is list-initialized (9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>]).</P></LI></UL>

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

<UL><LI><P>Otherwise, if the initializer list has a single element,
the object <INS>or reference</INS> is initialized from that element;
if a narrowing conversion (see below) is required to convert the
element to <TT>T</TT>, the program is ill-formed.</P></LI></UL>

</OL>

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