This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2832. Invented temporary variables and temporary objects

Section: 6.7.7  [class.temporary]     Status: open     Submitter: Thomas Köppe     Date: 2023-11-09

(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. ...