Skip to content

CWG2771 [class.mfct.non.static] p2 The transformation does not apply to the unqualified-id that is an operand of & #366

@xmh0511

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[class.mfct.non.static] p2 says:

When an id-expression ([expr.prim.id]) that is neither part of a class member access syntax ([expr.ref]) nor the unparenthesized operand of the unary & operator ([expr.unary.op]) is used where the current class is X ([expr.prim.this]), ..., the id-expression is transformed into a class member access expression ([expr.ref]) using (*this) as the postfix-expression to the left of the . operator.

Consider this case:

struct A{
   int a;
   void show(){
      int* r = &a; // #1 
   }
};

According to [class.mfct.non.static] p2, id-expression a(especially, unqualified-id) is the operand of the unary & operand, hence the transformation shouldn't apply to this case, however, all implementations accept this example.

Suggested Resolution

We may want to say

When an id-expression ([expr.prim.id]) that is neither:

part of a class member access syntax ([expr.ref]), nor
the unparenthesized operand of the unary & operator ([expr.unary.op]) if the id-expression is an qualified-id

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