This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
The term "temporary expression" is used in 11.9.3 [class.base.init] paragraph 8 and 11.9.3 [class.base.init] paragraph 11, but is never defined.
Proposed resolution (approved by CWG 2023-11-10):
Change in 6.7.7 [class.temporary] paragraph 6 as follows:
The third context is when a reference binds to a temporary object. [ Footnote: ... ]The temporary object to which the reference is bound or the temporary object that is the complete object of a subobject to which the reference is bound persists for the lifetime of the reference if the glvalue to which the reference is bound wasA temporary expression is a glvalue obtained through one of the following:If a reference is bound to an object O that is the result of a temporary expression, the complete object of O persists for the lifetime of the reference.
- a temporary materialization conversion (7.3.5 [conv.rval]),
- ( expression ), where expression is
one of these expressionsa temporary expression,- subscripting (7.6.1.2 [expr.sub]) of an array operand, where that operand is
one of these expressionsa temporary expression,- a class member access (7.6.1.5 [expr.ref]) using the . operator where the left operand is
one of these expressionsa temporary expression and the right operand designates a non-static data member of non-reference type,- a pointer-to-member operation (7.6.4 [expr.mptr.oper]) using the .* operator where the left operand is
one of these expressionsa temporary expression and the right operand is a pointer to data member of non-reference type,- a
converting, without a user-defined conversion, a glvalue operand that is
- const_cast (7.6.1.11 [expr.const.cast]),
- static_cast (7.6.1.9 [expr.static.cast])
- dynamic_cast (7.6.1.7 [expr.dynamic.cast]), or
- reinterpret_cast (7.6.1.10 [expr.reinterpret.cast])
one of these expressionsa temporary expression to a glvalue that refers to the object designated by the operand, or to its complete object or a subobject thereof,- a conditional expression (7.6.16 [expr.cond]) that is a glvalue where the second or third operand is
one of these expressionsa temporary expression, or- a comma expression (7.6.20 [expr.comma]) that is a glvalue where the right operand is
one of these expressionsa temporary expression.
Change in 11.9.3 [class.base.init] paragraph 8 as follows:
A temporary expression bound toBinding a reference member to an object that is the result of a temporary expression in a mem-initializer is ill-formed.
Change in 11.9.3 [class.base.init] paragraph 11 as follows:
A temporary expression bound toBinding a reference member to an object that is the result of a temporary expression from a default member initializer is ill-formed.
CWG 2024-03-21
The phrasing "If a reference is bound to an object O that is the result of a temporary expression, ..." can be interpreted to refer to any temporary expression, even one entirely unrelated to the initializer of the reference.