Title
Invented temporary variables and temporary objects
Status
open
Section
6.7.7 [class.temporary]
Submitter
Thomas Köppe

Created on 2023-11-09.00:00:00 last changed 13 months ago

Messages

Date: 2023-11-09.00:00:00

(From editorial issue 6646.)

Both 7.3.1 [conv.general] and 7.6.1.9 [expr.static.cast] introduce "invented temporary variables", but it is unclear whether the corresponding objects are temporary objects with lifetimes as specified in 6.7.7 [class.temporary].

Possible resolution:

  1. Change in 6.7.7 [class.temporary] as follows:

  2. Change in 7.3.1 [conv.general] paragraph 3 and paragraph 4 as follows, moving the declarations into a code block:

    An expression E can be implicitly converted to a type T if and only if the declaration

      T t = E;
    
    is well-formed, for some invented temporary variable t (6.7.7 [class.temporary], 9.4 [dcl.init]).

    Certain language constructs require that an expression be converted to a Boolean value. An expression E appearing in such a context is said to be contextually converted to bool and is well-formed if and only if the declaration

      bool t(E);
    
    is well-formed, for some invented temporary variable t (6.7.7 [class.temporary], 9.4 [dcl.init]).

  3. Change in 7.6.1.9 [expr.static.cast] as follows:

    ... If T is a reference type, the effect is the same as performing the declaration and initialization
      T t(E);
    
    for some invented temporary variable t (6.7.7 [class.temporary], 9.4 [dcl.init]) and then using the temporary variable as the result of the conversion. ...
History
Date User Action Args
2023-11-09 00:00:00admincreate