<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2107</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="2107"></A><H4>2107.
  
Lifetime of temporaries for default arguments in array copying
</H4>
<B>Section: </B>6.8.7&#160; [<A href="https://wg21.link/class.temporary">class.temporary</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Hubert Tong
 &#160;&#160;&#160;

 <B>Date: </B>2015-03-19<BR>


<P>[Adopted at the February, 2016 meeting.]</P>



<P>The lifetime of temporaries introduced for default
arguments in array copying is not specified clearly.
Presumably it should be treated like default arguments in
default constructors (6.8.7 [<A href="https://wg21.link/class.temporary">class.temporary</A>] paragraph
4), which deletes each element's set of default argument
temporaries before construction of the next element.</P>

<P><B>Proposed resolution (September, 2015):</B></P>

<P>Change 6.8.7 [<A href="https://wg21.link/class.temporary">class.temporary</A>] paragraphs 4-5 as follows:</P>

<BLOCKQUOTE>

<P>There are <DEL>two</DEL> <INS>three</INS> contexts in which temporaries
are destroyed at a different point than the end of the full-expression. The
first context is when a default constructor is called to initialize an
element of an array <INS>with no corresponding initializer
(9.5 [<A href="https://wg21.link/dcl.init">dcl.init</A>]). The second context is when a copy constructor
is called to copy an element of an array while the entire array is copied
(7.5.6 [<A href="https://wg21.link/expr.prim.lambda">expr.prim.lambda</A>],
11.4.5.3 [<A href="https://wg21.link/class.copy.ctor">class.copy.ctor</A>])</INS>. <DEL>If</DEL> <INS>In either case,
if</INS> the constructor has one or more default arguments, the destruction
of every temporary created in a default argument is sequenced before the
construction of the next array element, if any.</P>

<P>The <DEL>second</DEL> <INS>third</INS> context is when a reference is
bound to a temporary.<SUP>117</SUP> The temporary to which the reference is
bound...</P>

</BLOCKQUOTE>

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