Test case: namespace P{ namespace X { static int i = 1; } } namespace Q { namespace X = P::X; } using namespace P; using namespace Q; int main() { X::i; } Command line: g++ prog.cc -std=c++14 -pedantic-errors This results in name-lookup ambiguity errors when looking up X in main. This is not a name-lookup ambiguity since the two names founds denotes the same entity. I tried this with gcc HEAD 6.0.0 20150730 here: http://melpon.org/wandbox/permlink/6IBZhBmgDMkq6Eho
I have reported the same bug in clang also: https://llvm.org/bugs/show_bug.cgi?id=24324 Richard Smith confirmed it and added this additional test case: And likewise: namespace N {} namespace N = N; If a namespace alias really just binds a name to an existing namespace, the above should be valid, because all declarations of name N in the TU refer to the same entity.
Author: nathan Date: Tue Jun 20 12:53:11 2017 New Revision: 249408 URL: https://gcc.gnu.org/viewcvs?rev=249408&root=gcc&view=rev Log: PR c++/67074 - namespace aliases * decl.c (duplicate_decls): Don't error here on mismatched namespace alias. * name-lookup.c (name_lookup::add_value): Matching namespaces are not ambiguous. (diagnose_name_conflict): Namespaces are never redeclarations. (update_binding): An alias can match a real namespace. PR c++/67074 * g++.dg/lookup/pr67074.C: New. * g++.dg/parse/namespace-alias-1.C: Adjust. Added: trunk/gcc/testsuite/g++.dg/lookup/pr67074.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/cp/name-lookup.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/parse/namespace-alias-1.C
Fixed r249408.