This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


We need to instantiate a deferred noexcept when evaluationg __has_nothrow_constructor.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
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<>);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]