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

[dcl.meaning.general] p2.3 Correspond to a declaration that inhabits the block scope is not sufficient #5148

Closed
xmh0511 opened this issue Dec 14, 2021 · 0 comments · Fixed by #5149
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Dec 14, 2021

[dcl.meaning.general] p2.3 says that

Otherwise, the terminal name of E is not looked up. The declaration's target scope is the innermost enclosing namespace scope; if the declaration is contained by a block scope, the declaration shall correspond to a declaration that inhabits the innermost block scope.

Consider this example

void fun(){
   struct A{
    friend void show();  // #1
   };
   void show();  // #2
}

#1 does correspond to #2 but this example is rejected by all implementations that correctly implement the c++20 standard. In that standard, we require the example to satisfy the following rules

[class.friend] p11

If a friend declaration appears in a local class ([class.local]) and the name specified is an unqualified name, a prior declaration is looked up without considering scopes that are outside the innermost enclosing non-class scope. For a friend function declaration, if there is no prior declaration, the program is ill-formed.

the wording "correspond" does not guarantee the order of two declarations. It seems that we want the following rules to constrain this example

Otherwise, the terminal name of E is not looked up. The declaration's target scope is the innermost enclosing namespace scope; if the declaration is contained by a block scope, the declaration shall correspond to a reachable([module.reach#3]) declaration that inhabits the innermost block scope.

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

Successfully merging a pull request may close this issue.

2 participants