* [C++ PATCH] Fix ... handling in more_specialized_fn (PR c++/33962)
@ 2007-11-19 16:36 Jakub Jelinek
2007-11-20 11:45 ` Mark Mitchell
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-11-19 16:36 UTC (permalink / raw)
To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches
Hi!
If args1 and/or args2 are arguments of a function with ellipsis, then
len can be bigger than the number of arguments in the list.
The old more_specialized code would just stop when reaching
this, I don't see how can it deduce anything against ...
Regtested on x86_64-linux, ok for trunk?
2007-11-19 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.
* g++.dg/overload/template3.C: New test.
--- gcc/cp/pt.c.jj 2007-11-19 09:48:36.000000000 +0100
+++ gcc/cp/pt.c 2007-11-19 12:00:31.000000000 +0100
@@ -13544,6 +13544,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.jj 2007-11-19 12:02:23.000000000 +0100
+++ gcc/testsuite/g++.dg/overload/template3.C 2007-11-19 12:06:16.000000000 +0100
@@ -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" } } */
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ PATCH] Fix ... handling in more_specialized_fn (PR c++/33962)
2007-11-19 16:36 [C++ PATCH] Fix ... handling in more_specialized_fn (PR c++/33962) Jakub Jelinek
@ 2007-11-20 11:45 ` Mark Mitchell
0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2007-11-20 11:45 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jason Merrill, gcc-patches
Jakub Jelinek wrote:
> 2007-11-19 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.
>
> * g++.dg/overload/template3.C: New test.
OK.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-20 5:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-19 16:36 [C++ PATCH] Fix ... handling in more_specialized_fn (PR c++/33962) Jakub Jelinek
2007-11-20 11:45 ` Mark Mitchell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).