[Bug c++/63705] function template specialization outside namespace rejected with C++11

trippels at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Nov 1 13:27:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63705

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-01
     Ever confirmed|0                           |1

--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
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



More information about the Gcc-bugs mailing list