https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71173
Bug ID: 71173 Summary: [6 regression] Qualified name lookup Product: gcc Version: 6.1.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 foo { namespace bar { class foo {}; } class baz {}; } using namespace foo::bar; ::foo::baz mybaz; but GCC 6 reports (http://melpon.org/wandbox/permlink/2n9QQUT0UIXog2Cj): prog.cc:9:8: error: 'baz' in 'class foo::bar::foo' does not name a type ::foo::baz mybaz; ^~~ The name `::foo` should refer to the namespace `::foo`, not to the class `::foo::bar::foo` per [namespace.qual]/2: For a namespace X and name m, the namespace-qualified lookup set S(X,m) is defined as follows: Let S0(X,m) be the set of all declarations of m in X and the inline namespace set of X (7.3.1). If S0(X,m) is not empty, S(X,m) is S0(X,m); otherwise, S(X,m) is the union of S(Ni,m) for all namespaces Ni nominated by using-directives in X and its inline namespace set. S0(::,foo) is not empty, so namespaces nominated by using-directives should never be examined.