cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[basic.lookup.general] p1 Name lookup does not apply to the name of a declaration that is being declared #538

Open xmh0511 opened 1 month ago

xmh0511 commented 1 month ago

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

[basic.lookup.general] p1 says:

The name lookup rules apply uniformly to all names (including typedef-names ([dcl.typedef]), namespace-names ([basic.namespace]), and class-names ([class.name])) wherever the grammar allows such names in the context discussed by a particular rule.

[basic.pre] p4 says:

A name is an identifier ([lex.name]), operator-function-id ([over.oper]), literal-operator-id ([over.literal]), or conversion-function-id ([class.conv.fct]).

Consider this example:

int a = 0;
class B{};

The a in the declarator-id is an identifier, which is thereof a name, however, there would be nothing to be found if the lookup name applied to a. The same is true for the class-name B.

Suggested Resolution

Name lookup does not apply to the name in declarator-id, class-name and so on that are being declared in a declaration.

t3nsor commented 1 month ago

a is covered by http://eel.is/c++draft/dcl.meaning.general#3.4 B is covered by http://eel.is/c++draft/class.pre#1

xmh0511 commented 1 month ago

[basic.lookup.general] p1 should still say

Unless otherwise specified, the name lookup rules apply uniformly to all names ...