Patchwork C++ PATCH for c++/49229 (ICE with substitution failure)

login
register
mail settings
Submitter Jason Merrill
Date June 16, 2011, 9:48 p.m.
Message ID <4DFA7A2A.3010702@redhat.com>
Download mbox | patch
Permalink /patch/100731/
State New
Headers show

Comments

Jason Merrill - June 16, 2011, 9:48 p.m.
Another missing check for error_mark_node in SFINAE.

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

Patch

commit 2451aadf094bf8e65bf5a5fa28bbe3829c5a399e
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 15 13:39:42 2011 -0400

    	PR c++/49229
    	* pt.c (tsubst_decl) [FUNCTION_DECL]: Handle substitution failure.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ff145a2..1008b3b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9548,6 +9548,8 @@  tsubst_decl (tree t, tree args, tsubst_flags_t complain)
                                           (DECL_TEMPLATE_RESULT
                                                  (DECL_TI_TEMPLATE (t))),
 					   args, complain, in_decl);
+	    if (argvec == error_mark_node)
+	      RETURN (error_mark_node);
 
 	    /* Check to see if we already have this specialization.  */
 	    hash = hash_tmpl_and_args (gen_tmpl, argvec);
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae26.C b/gcc/testsuite/g++.dg/cpp0x/sfinae26.C
new file mode 100644
index 0000000..5b8cdd9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae26.C
@@ -0,0 +1,38 @@ 
+// PR c++/49229
+// { dg-options -std=c++0x }
+
+extern void* enabler;
+
+template<bool, class = void>
+struct enable_if {};
+
+template<class T>
+struct enable_if<true, T> {
+  typedef T type;
+};
+
+template<class... Bn>
+struct and_;
+
+template<class B1>
+struct and_<B1> : B1 {};
+
+template<class, class>
+struct is_same {
+  static constexpr bool value = false;
+};
+
+template<class T>
+struct is_same<T, T> {
+  static constexpr bool value = true;
+};
+
+template<class... T>
+struct S {
+  template<class... U,
+    typename enable_if<and_<is_same<T, U>...>::value>::type*& = enabler
+  >
+  S(U...){} // #
+};
+
+S<bool> s(0);			// { dg-error "no match" }