Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[basic.lookup.qual.general] p2 Improve the definition of a member-qualified name #5127

Open
xmh0511 opened this issue Nov 25, 2021 · 1 comment

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Nov 25, 2021

In the current draft, the definition of a member-qualified name is that

A member-qualified name is the (unique) component name ([expr.prim.id.unqual]), if any, of

  • an unqualified-id or
  • a nested-name-specifier of the form type-name ​::​ or namespace-name ​::​

in the id-expression of a class member access expression ([expr.ref]).

Here, "in" can be interpreted by its English meaning, which can result in an issue arisen from this example

struct C{
    int member;
};
struct D:C{};
struct E:D{};
struct F:E{};
int main(){
   E e;
   e.F::D::C::member = 0;  // #1
}

the id-expression of the class member access expression at #1 is F::D::C::member obeying the grammar nested-name-specifier template opt unqualified-id , that is, member is the unqualified-id in this id-expression of the class member access expression. Does it mean member is a member-qualified name? It seems this is not the intent of that rule. Conversely, F can be a member-qualified name since the nested-name-specifier to which it belongs obeys the form type-name ​::​ and is in the id-expression.

My opinion is that the above rule may be improved to be that

A member-qualified name is the (unique) component name ([expr.prim.id.unqual]), if any, of

  • an unqualified-id that is the id-expression or
  • a nested-name-specifier of the form type-name ​::​ or namespace-name ​::​ in the id-expression

of a class member access expression ([expr.ref]).

@jensmaurer
Copy link
Member

jensmaurer commented Nov 25, 2021

@opensdh , that's your bailiwick. This looks like a clarity improvement to me, but I wonder whether there's a less awkward way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants