https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70522
Bug ID: 70522 Summary: Hidden friend functions block qualified name lookup into nested unnamed namespace Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Casey at Carter dot net Target Milestone: --- This program should compile without error: namespace N { struct S { friend void f(S&) {} }; namespace { int f; } } int main() { N::f = 42; } yet GCC 6 diagnoses: prog.cc: In function 'int main()': prog.cc:11:5: error: 'f' is not a member of 'N' N::f = 42; ^ prog.cc:11:5: note: suggested alternative: prog.cc:6:13: note: 'N::{anonymous}::f' int f; ^ The program compiles correctly if either the friend declaration of f is commented out, or the unnamed namespace is made an inline namespace. Language lawyer justification: The friend declaration of f is not visible to name lookup of N::f per [namespace.memdef]/3, so the set of declarations S'(N,f) described in [namespace.qual]/2 is empty. Name lookup should continue into namespaces "nominated by using directives" in N; unnamed namespaces are such namespaces per [namespace.unnamed]/1.