Lifetime of temporaries bound to comma expressions
6.7.7 [class.temporary]
Steve Adamczyk

Created on 2004-04-09.00:00:00 last changed 90 months ago


Date: 2012-02-15.00:00:00

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

Date: 2006-11-15.00:00:00

Proposed Resolution (November, 2006):

Add the indicated wording to 7.6.20 [expr.comma] paragraph 1:

... 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. If the value of the right operand is a temporary (6.7.7 [class.temporary]), the result is that temporary.
Date: 2005-04-15.00:00:00

Notes from the April, 2005 meeting:

The CWG suggested a different approach from the 10/2004 resolution, leaving 6.7.7 [class.temporary] unchanged and adding normative wording to 7.6.20 [expr.comma] specifying that, if the result of the second operand is a temporary, that temporary is the result of the comma expression as well.

Date: 2004-10-15.00:00:00

Proposed resolution (October, 2004):

Change 6.7.7 [class.temporary] paragraph 2 as indicated:

... In all these cases, the temporaries created during the evaluation of the expression initializing the reference, except the temporary that is the overall result of the expression [Footnote: For example, if the expression is a comma expression (7.6.20 [expr.comma]) and the value of its second operand is a temporary, the reference is bound to that temporary.] and 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...

[Note: this wording partially resolves issue 86. See also issue 446.]

Date: 2004-03-15.00:00:00

Notes from the March 2004 meeting:

We think the temporary should be extended.

Date: 2004-04-09.00:00:00

Split off from issue 86.

Should binding a reference to the result of a "," operation whose second operand is a temporary extend the lifetime of the temporary?

  const SFileName &C = ( f(), SFileName("abc") );
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2012-11-03 00:00:00adminsetstatus: dr -> drwp
2012-02-27 00:00:00adminsetmessages: + msg3825
2012-02-27 00:00:00adminsetstatus: ready -> dr
2011-09-06 00:00:00adminsetstatus: review -> ready
2008-02-03 00:00:00adminsetmessages: + msg1564
2008-02-03 00:00:00adminsetstatus: drafting -> review
2005-05-01 00:00:00adminsetmessages: + msg1162
2005-05-01 00:00:00adminsetstatus: review -> drafting
2004-11-07 00:00:00adminsetmessages: + msg1063
2004-11-07 00:00:00adminsetstatus: open -> review
2004-04-09 00:00:00adminsetmessages: + msg992
2004-04-09 00:00:00admincreate