Created attachment 41695 [details] Preprocessed test.cpp Compile test.cpp below using libc++ headers: -----test.cpp----- #include <set> class C { std::set<int> s; }; #include <map> using std::map; ------------------ $ g++ -c test.cpp -nostdinc++ -isystem/path/to/libc++/trunk/include g++ fails to compile and gives: main.cpp:9:12: error: ‘map’ is already declared in this scope using std::map; I've attached a preprocessed output for convenience. $ g++ -c test_preproc.cpp 2>/dev/null && echo pass || echo fail fail $ clang++ -c test_preproc.cpp 2>/dev/null && echo pass || echo fail pass
Sounds like a bug in libc++ headers to me -> file to the LLVM project.
No, this is definitely a GCC bug: namespace A { template <class> class tree { template <class> friend class map; }; } A::tree<int> x; namespace A { template <class> class map { }; } using A::map;
I would guess that the instantiation of A::tree injects the type map into the enclosing namespace, and then the using-declaration finds two declarations and thinks it's an error. bug.cc:17:10: error: ‘map’ is already declared in this scope using A::map; ^~~
Duplicate of bug#59930 (friend class templates in class templates get injected into the global namespace instead of the innermost enclosing namespace)?
Fixed by r255780 so closing as a dup, as Richard suggested. *** This bug has been marked as a duplicate of bug 59930 ***