Skip to content

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

Open
@xmh0511

Description

@xmh0511

[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.

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