This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/39742
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 13 Apr 2009 00:12:29 -0400
- Subject: C++ PATCH for c++/39742
Pretty clear. I was failing to consider variadics in the logic.
Tested x86_64-pc-linux-gnu, applied to trunk and 4.4.
2009-04-12 Jason Merrill <jason@redhat.com>
PR c++/39742
* call.c (joust): Don't crash on variadic fn.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c942712..24a5bcc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6801,6 +6801,9 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
for (i = 0; i < len; ++i)
{
+ /* Don't crash if the fn is variadic. */
+ if (!parms1)
+ break;
parms1 = TREE_CHAIN (parms1);
parms2 = TREE_CHAIN (parms2);
}
diff --git a/gcc/testsuite/g++.dg/overload/extern-C-2.C b/gcc/testsuite/g++.dg/overload/extern-C-2.C
new file mode 100644
index 0000000..562786c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/extern-C-2.C
@@ -0,0 +1,22 @@
+// PR c++/39742
+
+void f( int, ...);
+
+struct S
+{
+};
+
+void
+g()
+{
+ void f( int, ...);
+
+ S t;
+
+ f(1, t);
+}
+
+void
+f( int i, ...)
+{
+}