This should not be accepted in C++11 mode: namespace A { template<typename T> struct B { }; } using A::B; template class B<int>; [temp.explicit] p3: "An explicit instantiation shall appear in an enclosing namespace of its template. If the name declared in the explicit instantiation is an unqualified name, the explicit instantiation shall appear in the namespace where its template is declared or, if that namespace is inline (7.3.1), any namespace from its enclosing namespace set." This is a change from C++03: "A definition of a class template or class member template shall be in scope at the point of the explicit instantiation of the class template or class member template."
Author: redi Date: Tue Apr 15 19:05:45 2014 New Revision: 209431 URL: http://gcc.gnu.org/viewcvs?rev=209431&root=gcc&view=rev Log: PR c++/60786 * testsuite/20_util/shared_ptr/requirements/explicit_instantiation/ 1.cc: Fix invalid explicit instantiations with unqualified names. * testsuite/20_util/shared_ptr/requirements/explicit_instantiation/ 2.cc: Likweise. * testsuite/20_util/tuple/53648.cc: Likweise. * testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc: Likewise. * testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/23_containers/unordered_map/requirements/ debug_container.cc: Likewise. * testsuite/23_containers/unordered_map/requirements/ explicit_instantiation/3.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/debug.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/ explicit_instantiation/3.cc: Likewise. * testsuite/23_containers/unordered_multiset/requirements/debug.cc: Likewise. * testsuite/23_containers/unordered_multiset/requirements/ explicit_instantiation/3.cc: Likewise. * testsuite/23_containers/unordered_set/requirements/ debug_container.cc: Likewise. * testsuite/23_containers/unordered_set/requirements/ explicit_instantiation/3.cc: Likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc trunk/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc trunk/libstdc++-v3/testsuite/20_util/tuple/53648.cc trunk/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc trunk/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/debug_container.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_map/requirements/explicit_instantiation/3.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/debug.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_multimap/requirements/explicit_instantiation/3.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/debug.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc trunk/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc
I've fixed the libstdc++ tests so they don't rely on this bug
Clang rejects the code.
In GCC7+, we started having a pedantic warning (only with -pedantic or -Wpedantic): <source>:6:16: warning: explicit instantiation of 'template<class T> struct A::B' outside its namespace must use a nested-name-specifier [-Wpedantic] template class B<int>; ^~~~~~ This is a dup of bug 56480. *** This bug has been marked as a duplicate of bug 56480 ***