Skip to content

CWG3215 [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])

Activity

  1. jensmaurer commented on Aug 9, 2026

    @jensmaurer
    Member
  2. changed the title [-][expr.const.core] Using this in a default member initializer during constant evaluation[/-] [+]CWG3215 [expr.const.core] Using this in a default member initializer during constant evaluation[/+] on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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