Please consider: markus@x4 ~ % cat te.ii namespace N { template <typename T1> void f (const T1) {} } template <> void N::f (const int) {} markus@x4 ~ % clang++ -std=c++11 -c te.ii markus@x4 ~ % icpc -std=c++11 -c te.ii markus@x4 ~ % g++ -std=c++11 -c te.ii te.ii:10:16: error: specialization of ‘template<class T1> void N::f(T1)’ in different namespace [-fpermissive] N::f (const int) {} ^ te.ii:5:1: error: from definition of ‘template<class T1> void N::f(T1)’ [-fpermissive] f (const T1) {} ^ markus@x4 ~ % clang++ -c te.ii te.ii:10:4: warning: first declaration of function template specialization of 'f' outside namespace 'N' is a C++11 extension [-Wc++11-extensions] N::f (const int) {} ^ te.ii:5:1: note: explicitly specialized declaration is here f (const T1) {}
Not a regression.
See also: https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/ZCRb8iZwtos
Possible (untested) fix: diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2cf10f4..1171b5d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -780,15 +780,15 @@ check_specialization_namespace (tree tmpl) error ("specialization of %qD must appear at namespace scope", tmpl); return false; } - if (is_associated_namespace (current_namespace, tpl_ns)) - /* Same or super-using namespace. */ - return true; - else + if (!is_associated_namespace (current_namespace, tpl_ns) && + (cxx_dialect < cxx11)) { permerror (input_location, "specialization of %qD in different namespace", tmpl); permerror (input_location, " from definition of %q+#D", tmpl); return false; } + + return true; } /* SPEC is an explicit instantiation. Check that it is valid to
PR 56480 ?
(In reply to Jonathan Wakely from comment #4) > PR 56480 ? Yes. Thanks. *** This bug has been marked as a duplicate of bug 56480 ***