Skip to content

CWG2902 [expr.prim.id.general] Transformation of id-expressions to non-static non-type members in class scope #553

Description

Full name of submitter: Vincent X

Reference: [expr.prim.id.general]

Issue description: P1787R6 effectively relaxed the constraints on the transformation of id-expressions (to non-static non-type members) in class scope into class member access expressions, such that they may be transformed even if the expression this is not allowed in the context. Consider:

struct A {
  int x;
  int a[sizeof(x)]; // (1)
  decltype(x) f();  // (2)
};

Under the current rules of [expr.prim.id.general]/2, both expressions of x in (1) and (2) are transformed into (*this).x, making the declarations ill-formed. This is because P1787R6 removed the old constraint (as referenced in #[class.mfct.non-static]):

[...] in a context where this can be used [...]

Suggested resolution: Reintroduce the constraint where appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions