cplusplus / cplusplus/draft

[class.mfct.non-static] p3 class member access transformation in the context where "this" is not permitted

Open
#4,914 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[class.mfct.non-static] p3

When an id-expression ([expr.prim.id]) that is not part of a class member access syntax ([expr.ref]) and not used to form a pointer to member ([expr.unary.op]) is used where the current class is X ([expr.prim.this]), if name lookup ([basic.lookup]) resolves the name in the id-expression to a non-static non-type member of some class C, and if either the id-expression is potentially evaluated or C is X or a base class of X, 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 example

struct B{
    int d;
    void show(decltype(d));  // #1
};

the name d in #1 resolves to the non-static data member of B, the current class is also B, hence the id-expression is transformed into a class member access expression, however, according to [expr.prim.this] p5

The expression this shall not appear in any other context.

The transformation makes an ill-formed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read [class.mfct.non-static] p3 alongside [expr.prim.this] p5 and the example involving decltype(d) in a member declaration. Determine how the transformation should interact with contexts where this is not permitted, then update the relevant standard wording so the example's validity is unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.