Patchwork [C++] PR 47974

login
register
mail settings
Submitter Paolo Carlini
Date March 3, 2011, 4:11 p.m.
Message ID <4D6FBDC8.5070504@oracle.com>
Download mbox | patch
Permalink /patch/85295/
State New
Headers show

Comments

Paolo Carlini - March 3, 2011, 4:11 p.m.
Hi,

another ICE on invalid, 4.6 regression, a simple patch for it attached.
Tested x86_64-linux.

Ok?

Thanks,
Paolo.
/cp
2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/47974
	* pt.c (tsubst_template_args): Check argument t for error_mark_node.

/testsuite
2011-03-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/47974
	* g++.dg/template/crash106.C: New.
Jason Merrill - March 3, 2011, 4:53 p.m.
OK.

Jason

Patch

Index: testsuite/g++.dg/template/crash106.C
===================================================================
--- testsuite/g++.dg/template/crash106.C	(revision 0)
+++ testsuite/g++.dg/template/crash106.C	(revision 0)
@@ -0,0 +1,12 @@ 
+// PR c++/47974
+
+typedef double T;
+
+struct A
+{
+  template<T> void foo(); // { dg-error "type" }
+};
+
+template<T N = 0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type|declared" }
+
+B<> b; // { dg-error "type|declaration" }
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 170651)
+++ cp/pt.c	(working copy)
@@ -8966,10 +8966,15 @@  static tree
 tsubst_template_args (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 {
   tree orig_t = t;
-  int len = TREE_VEC_LENGTH (t);
-  int need_new = 0, i, expanded_len_adjust = 0, out;
-  tree *elts = XALLOCAVEC (tree, len);
+  int len, need_new = 0, i, expanded_len_adjust = 0, out;
+  tree *elts;
 
+  if (t == error_mark_node)
+    return error_mark_node;
+
+  len = TREE_VEC_LENGTH (t);
+  elts = XALLOCAVEC (tree, len);
+
   for (i = 0; i < len; i++)
     {
       tree orig_arg = TREE_VEC_ELT (t, i);