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] lookup context vs. cv-qualified that type #5351

Open
xmh0511 opened this issue Mar 18, 2022 · 1 comment · May be fixed by #6424
Open

[basic.lookup] lookup context vs. cv-qualified that type #5351

xmh0511 opened this issue Mar 18, 2022 · 1 comment · May be fixed by #6424

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Mar 18, 2022

[basic.lookup.qual.general] p2 define the lookup context:

The lookup context of a member-qualified name is the type of its associated object expression (considered dependent if the object expression is type-dependent). The lookup context of any other qualified name is the type, template, or namespace nominated by the preceding nested-name-specifier.

[basic.lookup.qual.general] p3 states

Qualified name lookup in a class, namespace, or enumeration performs a search of the scope associated with it ([class.member.lookup]) except as specified below.

Consider a case where the type is not a pure class type

struct C{
   int c = 0;
};
typedef C const CC;
int main(){
  sizeof(CC::c) + CC{}.c;

}

both the lookup context of c is const-qualified class C. [class.member.lookup] just define the lookup process as:

The declaration set is the result of a single search in the scope of C for N from immediately after the class-specifier of C if P is in a complete-class context of C or from P otherwise.

It didn't state what the result is if the lookup context is const C. [class.pre] p1 state

A class is a type.

[basic.type.qualifier] p1 states

Each type other than a function or reference type is part of a group of four distinct, but related, types

[basic.scope.class] p1 states

Any declaration of a class or class template C introduces a class scope

In the above example, the declaration of class C introduces the scope. Maybe, we could arguably say the scope of C is associated with const C.


In addition, [class.member.lookup] also has an unclear definition

[class.member.lookup] p2 states:

The lookup set for N in C, called S( N, C ) consists of two component sets

The declaration set is the result of a single search in the scope of C for N from immediately after the class-specifier of C

From this point, the symbol C should be a class type. However, that symbol in the following two bullets will be interpreted as an object

If the resulting declaration set is not empty, the subobject set contains C itself, and calculation is complete.

Calculate the lookup set for N in each direct non-dependent ([temp.dep.type]) base class subobject Bi and merge each such lookup set S( N, Bi ) in turn into S( N, C )

Then, [class.member.lookup] p6, in turn, call the second symbol of set S as a class

The result of the search is the declaration set of S( N, T )

where T is previously defined as class or class template T in p1.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Mar 19, 2022

For the first part of this issue, I think [basic.lookup.qual.general] p2 should be changed to

The lookup context of a member-qualified name is the cv-unqualified version of the type of its associated object expression (considered dependent if the object expression is type-dependent). The lookup context of any other qualified name is the cv-unqualified version of the type, template, or namespace nominated by the preceding nested-name-specifier.

This may eliminate the interference that we say lookup performs a search in the scope of a class whereas the lookup context is the cv-qualified that class(type).

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