Hi,
seems an easy issue: we aren't allowing an explicit specializations
differing from the template declaration with respect to the constexpr
specifier.
Tested x86_64-linux.
Thanks,
Paolo.
//////////////////////
/cp
2013-04-08 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/56871
* decl.c (validate_constexpr_redeclaration): Allow an explicit
specialization to be different wrt the constexpr specifier.
/testsuite
2013-04-08 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/56871
* g++.dg/cpp0x/constexpr-specialization.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 197572)
+++ cp/decl.c (working copy)
@@ -1203,6 +1203,14 @@ validate_constexpr_redeclaration (tree old_decl, t
= DECL_DECLARED_CONSTEXPR_P (new_decl);
return true;
}
+ /* 7.1.5 [dcl.constexpr]
+ Note: An explicit specialization can differ from the template
+ declaration with respect to the constexpr specifier. */
+ if (TREE_CODE (old_decl) == FUNCTION_DECL
+ && TREE_CODE (new_decl) == FUNCTION_DECL
+ && ! DECL_TEMPLATE_SPECIALIZATION (old_decl)
+ && DECL_TEMPLATE_SPECIALIZATION (new_decl))
+ return true;
error ("redeclaration %qD differs in %<constexpr%>", new_decl);
error ("from previous declaration %q+D", old_decl);
return false;
Index: testsuite/g++.dg/cpp0x/constexpr-specialization.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-specialization.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-specialization.C (working copy)
@@ -0,0 +1,12 @@
+// PR c++/56871
+// { dg-options "-std=c++11" }
+
+template<typename T> constexpr int foo(T);
+template<> int foo(int);
+template<> int foo(int); // { dg-error "previous" }
+template<> constexpr int foo(int); // { dg-error "redeclaration" }
+
+template<typename T> int bar(T);
+template<> constexpr int bar(int);
+template<> constexpr int bar(int); // { dg-error "previous" }
+template<> int bar(int); // { dg-error "redeclaration" }