-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
name lookup in qualified friend declaration is extremely suspicious #38230
Comments
Is this another case of the same problem? namespace ns
{
struct S { };
void func(S) { }
}
struct X
{
friend void ns::func(S);
}; Other compilers accept this, but clang wants the friend decl to use
|
...or is the Clang behavior in line with [basic.scope.namespace]/1, since C++23 P1787R6: Declarations and where to find them explicitly stating "non-friend":
|
(which would be CWG2370 friend declarations of namespace-scope functions (which states "There is implementation divergence on these points."), reportedly "resolved by performing a search in (only) the immediate scope of any friend", P1787R6: Declarations and where to find them) |
I think the relevant rule is:
So in the new example, we should first look for In the original example, we should look for |
Extended Description
Testcase:
Here,
#1
resolvesT
as::T
, not as the template parameter. Strangely, we fail to diagnose this, and instead silently befriend nothing in line#1
.In
#2
,Y
resolves toN::Y
, not to the injected-class-name ofN::Y
, and as a result declaration#2
is rejected becauseY
is lacking its template arguments.These results both seem extremely surprising. The standard's rules here are highly unclear, but this cannot be the right behavior...
The text was updated successfully, but these errors were encountered: