Skip to content

[expr.const.core] Using this in a default member initializer during constant evaluation #949

Description

@t3nsor

Full name of submitter: Brian Bi

Issue description: [expr.const.core]/2.1 permits the use of this during constant evaluation only in a constexpr function or as the postfix-expression of a class member access expression. This rule appears to prohibit, e.g.

constexpr struct A {
    A* p = this;
} a;
static_assert(a.p == &a);

Suggested resolution: Edit [expr.const.core]/2.1 as follows:

  • this ([expr.prim.this]), except
    • in a constexpr function ([dcl.constexpr]) that is being evaluated as part of E or ,
    • in a default member initializer for an object that is being initialized as part of E, or
    • when appearing as the postfix-expression of an implicit or explicit class member access expression ([expr.ref])

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