From 63d34078b671ef7f3666daea632596f0885ee840 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 20 Nov 2007 07:26:11 +0100 Subject: [PATCH] re PR c++/33962 (ICE at call to overloaded template function with variable-length function argument list) 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 | 6 ++++++ gcc/cp/pt.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/overload/template3.C | 15 +++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.dg/overload/template3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 193931ddfc1..d8e95c68261 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-11-20 Jakub Jelinek + + 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 PR c++/30988 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5e1335f439a..4b09e856459 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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--; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e93fa8acfa6..585c7209b68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-11-20 Jakub Jelinek + + PR c++/33962 + * g++.dg/overload/template3.C: New test. + 2007-11-19 Jerry DeLisle 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 index 00000000000..90ccfd8add6 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/template3.C @@ -0,0 +1,15 @@ +// PR c++/33962 +// { dg-do compile } + +template struct A; + +template void foo (const U &x, ...); +template void foo (const A &x, ...); + +void bar (const A &x, const char *y) +{ + foo (x, y); +} + +/* { dg-final { scan-assembler "_Z3fooIiEvRK1AIT_Ez" } } */ +/* { dg-final { scan-assembler-not "_Z3fooI1AIiEEvRKT_z" } } */ -- 2.30.2