2016-03-30 Nathan Sidwell <nathan@acm.org>
PR c++/68475
* decl.c (check_redeclaration_exception_specification): Check
regardless of -fno-exceptions.
PR c++/68475
* g++.dg/eh/spec12.C: New.
===================================================================
@@ -1200,9 +1200,11 @@ check_redeclaration_exception_specificat
If any declaration of a function has an exception-specification,
all declarations, including the definition and an explicit
specialization, of that function shall have an
- exception-specification with the same set of type-ids. */
+ exception-specification with the same set of type-ids.
+
+ Even when fno-exceptions is in effect, any specifications must
+ still match. */
if (! DECL_IS_BUILTIN (old_decl)
- && flag_exceptions
&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
{
const char *msg
===================================================================
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// { dg-additional-options "-fno-exceptions" }
+
+// PR68475 we used to not check eh spec matching with -fno-exceptions,
+// but this could lead to ICEs.
+
+template < typename > struct traits;
+
+template < typename T > struct X
+{
+ X & operator = (X &&) noexcept (traits < T >::foo ()); // { dg-inform "previous declaration" }
+};
+
+template < typename T >
+X < T > &
+X < T >::operator = (X &&) noexcept (traits < T >::bar ()) // { dg-error "different exception specifier" }
+{
+ return *this;
+}