re PR c++/33962 (ICE at call to overloaded template function with variable-length...
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Nov 2007 06:26:11 +0000 (07:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Nov 2007 06:26:11 +0000 (07:26 +0100)
PR c++/33962
* pt.c (more_specialized_fn): Don't segfault if one or
both argument list end with ellipsis.

* g++.dg/overload/template3.C: New test.

From-SVN: r130308

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/template3.C [new file with mode: 0644]

index 193931ddfc17bee58c20487d76e189f70912292d..d8e95c682618aba539019de11924e63eca15c481 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33962
+       * pt.c (more_specialized_fn): Don't segfault if one or
+       both argument list end with ellipsis.
+
 2007-11-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/30988
index 5e1335f439ab8209eb13f28d28ae1952130e5838..4b09e856459a6fffacd55eee8096eeaf84ca3d1a 100644 (file)
@@ -13523,6 +13523,10 @@ more_specialized_fn (tree pat1, tree pat2, int len)
 
       args1 = TREE_CHAIN (args1);
       args2 = TREE_CHAIN (args2);
+
+      /* Stop when an ellipsis is seen.  */
+      if (args1 == NULL_TREE || args2 == NULL_TREE)
+       break;
     }
 
   processing_template_decl--;
index e93fa8acfa641272bdc734a75ee9646878476d5c..585c7209b68c540b379a750c4509f23f1f10dfdc 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33962
+       * g++.dg/overload/template3.C: New test.
+
 2007-11-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/33317
diff --git a/gcc/testsuite/g++.dg/overload/template3.C b/gcc/testsuite/g++.dg/overload/template3.C
new file mode 100644 (file)
index 0000000..90ccfd8
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/33962
+// { dg-do compile }
+
+template <class T> struct A;
+
+template <class U> void foo (const U &x, ...);
+template <class T> void foo (const A<T> &x, ...);
+
+void bar (const A<int> &x, const char *y)
+{
+  foo (x, y);
+}
+
+/* { dg-final { scan-assembler "_Z3fooIiEvRK1AIT_Ez" } } */
+/* { dg-final { scan-assembler-not "_Z3fooI1AIiEEvRKT_z" } } */