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. * g++.dg/overload/template3.C: New test. --- gcc/cp/pt.c (revision 130307) +++ gcc/cp/pt.c (revision 130308) @@ -13523,6 +13523,10 @@ more_specialized_fn (tree pat1, tree pat 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--; --- gcc/testsuite/g++.dg/overload/template3.C (revision 0) +++ gcc/testsuite/g++.dg/overload/template3.C (revision 130308) @@ -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" } } */