Patchwork C++ PATCH for c++/55842 (ICE with noexcept and __has_nothrow_constructor)

login
register
mail settings
Submitter Jason Merrill
Date Jan. 3, 2013, 8:34 p.m.
Message ID <50E5EB62.8030009@redhat.com>
Download mbox | patch
Permalink /patch/209308/
State New
Headers show

Comments

Jason Merrill - Jan. 3, 2013, 8:34 p.m.
We need to instantiate a deferred noexcept when evaluationg 
__has_nothrow_constructor.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.

Patch

commit 2b440f24a3319736c477523f65af741f97068ab6
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 3 14:38:54 2013 -0500

    	PR c++/55842
    	* semantics.c (trait_expr_value): Call maybe_instantiate_noexcept.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 9f8119f..2e02295 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5454,7 +5454,8 @@  trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
       return (trait_expr_value (CPTK_HAS_TRIVIAL_CONSTRUCTOR, type1, type2) 
 	      || (CLASS_TYPE_P (type1)
 		  && (t = locate_ctor (type1))
-		  && TYPE_NOTHROW_P (TREE_TYPE (t))));
+		  && (maybe_instantiate_noexcept (t),
+		      TYPE_NOTHROW_P (TREE_TYPE (t)))));
 
     case CPTK_HAS_TRIVIAL_CONSTRUCTOR:
       type1 = strip_array_types (type1);
diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C b/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C
new file mode 100644
index 0000000..9191c3e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/has_nothrow_constructor-2.C
@@ -0,0 +1,7 @@ 
+// PR c++/55842
+// { dg-options -std=c++11 }
+
+template <class=void> struct number {
+  number() noexcept(noexcept(0)) { }
+};
+const int z=__has_nothrow_constructor(number<>);