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

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

 <B>Submitter: </B>Steve Adamczyk
 &#160;&#160;&#160;

 <B>Date: </B>April 2004<BR>


<P>[Voted into the WP at the February, 2012 meeting;
moved to DR at the October, 2012 meeting.]</P>

<P>Split off from <A HREF="86.html">issue 86</A>.</P>

<P>Should binding a reference to the result of a "," operation
whose second operand is a temporary extend the lifetime of the
temporary?</P>
<PRE>
  const SFileName &amp;C = ( f(), SFileName("abc") );
</PRE>

<P><B>Notes from the March 2004 meeting:</B></P>

<P>We think the temporary should be extended.</P>

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

<P>Change 6.8.7 [<A href="https://wg21.link/class.temporary#2">class.temporary</A>] paragraph 2 as
indicated:</P>

<BLOCKQUOTE>

... In all these cases, the temporaries created during the
evaluation of the expression initializing the reference, except
the temporary <INS>that is the overall result of the expression
[<I>Footnote:</I> For example, if the expression is a comma
expression (7.6.20 [<A href="https://wg21.link/expr.comma">expr.comma</A>]) and the value of its
second operand is a temporary, the reference is bound to that
temporary.] and</INS> to which the reference is bound, are destroyed at
the end of the full-expression in which they are created and in
the reverse order of the completion of their construction...

</BLOCKQUOTE>

<P><I>[Note: this wording partially resolves <A HREF="86.html">issue 86</A>.  See also <A HREF="446.html">issue 446</A>.]</I></P>

<P><B>Notes from the April, 2005 meeting:</B></P>

<P>The CWG suggested a different approach from the 10/2004 resolution,
leaving 6.8.7 [<A href="https://wg21.link/class.temporary">class.temporary</A>] unchanged and adding normative
wording to 7.6.20 [<A href="https://wg21.link/expr.comma">expr.comma</A>] specifying that, if the result
of the second operand is a temporary, that temporary is the result of
the comma expression as well.</P>

<P><B>Proposed Resolution (November, 2006):</B></P>

<P>Add the indicated wording to 7.6.20 [<A href="https://wg21.link/expr.comma#1">expr.comma</A>] paragraph 1:</P>

<BLOCKQUOTE>

... The type and value of the result are the type and value of the
right operand; the result is of the same value category as its right
operand, and is a bit-field if its right operand is a glvalue and a
bit-field.  <INS>If the value of the right operand is a temporary
(6.8.7 [<A href="https://wg21.link/class.temporary">class.temporary</A>]), the result is that temporary.</INS>

</BLOCKQUOTE>

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