Skip to content

CWG2826 [class.temporary] Missing definition of "temporary expression" #200

@t3nsor

Description

@t3nsor

Full name of submitter: Brian Bi

Reference (section label): [class.temporary]

Issue description: The term "temporary expression" is currently used in two places in the standard: [class.base.init]/8 "A temporary expression bound to a reference member in a _mem-initializer is ill-formed." and [class.base.init]/11 "A temporary expression bound to a reference member from a default member initializer is ill-formed." However, this term has not been defined.

Suggested resolution:
Edit [class.temporary]/6:

The third context is when a reference binds to a temporary object. 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 was
A temporary expression is a glvalue obtained through one of the following:

  • a temporary materialization conversion (7.3.5),

  • ( expression ), where expression is one of these expressions a temporary expression,

  • subscripting (7.6.1.2) of an array operand, where that operand is one of these expressions a temporary expression,

  • a class member access (7.6.1.5) using the . operator where the left operand is one of these expressions a temporary expression and the right operand designates a non-static data member of non-reference type,

  • a pointer-to-member operation (7.6.4) using the .* operator where the left operand is one of these
    expressions
    a temporary expression and the right operand is a pointer to data member of non-reference type,

  • a

    • const_cast (7.6.1.11),
    • static_cast (7.6.1.9),
    • dynamic_cast (7.6.1.7), or
    • reinterpret_cast (7.6.1.10)

    converting, without a user-defined conversion, a glvalue operand that is one of these expressions temporary expression to a glvalue that refers to the object designated by the operand, or to its complete object or a subobject thereof,

  • a glvalue conditional expression (7.6.16) that is a glvalue designating either its second or third operand, where the selected operand is a temporary expression where the second or third operand is one of these expressions, or

  • a glvalue comma expression (7.6.20) that is a glvalue where the right operand is one of these expressions a temporary expression.

If the reference is bound to a temporary expression, the complete object of the object designated by the temporary expression persists for the lifetime of the reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions