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.carl...@oracle.com>

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

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

        PR c++/47974
        * g++.dg/template/crash106.C: New.
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);

Reply via email to