Is T() a temporary?
Section [expr.type.conv]

Created on 2009-07-14.00:00:00 last changed 27 months ago


Date: 2017-07-15.00:00:00

[Voted into the WP at the July, 2017 meeting as document P0727R0.]

Date: 2017-03-15.00:00:00

Proposed resolution (March, 2017):

This issue is resolved by the resolution of issue 1299.

Date: 2009-10-15.00:00:00

Notes from the October, 2009 meeting:

The specification in [expr.type.conv] is in error, not because it fails to state that T() is a temporary but because it requires a temporary for the other cases with fewer than two operands. The case where T is a class type is covered by 6.7.7 [class.temporary] paragraph 1 (“a conversion that creates an rvalue”), and a temporary should not be created when T is not a class type.

Date: 2009-07-14.00:00:00

According to [expr.type.conv] paragraphs 1 and 3 (stated directly or by reference to another section of the Standard), all the following expressions create temporaries:

    T(1, 2)

However, paragraph 2 says,

The expression T(), where T is a simple-type-specifier or typename-specifier for a non-array complete effective object type or the (possibly cv-qualified) void type, creates an rvalue of the specified type, which is value-initialized (9.4 [dcl.init]; no initialization is done for the void() case).

This does not say that the result is a temporary, which means that the lifetime of the result is not specified by 6.7.7 [class.temporary]. Presumably this is just an oversight.

Date User Action Args
2020-12-15 00:00:00adminsetstatus: drwp -> cd5
2018-02-27 00:00:00adminsetmessages: + msg6134
2018-02-27 00:00:00adminsetmessages: + msg6133
2018-02-27 00:00:00adminsetstatus: open -> drwp
2009-11-08 00:00:00adminsetmessages: + msg2399
2009-07-14 00:00:00admincreate