This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/43054 (bogus ambiguity error with template redeclaration and decltype)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 Feb 2010 15:08:26 -0500
- Subject: C++ PATCH for c++/43054 (bogus ambiguity error with template redeclaration and decltype)
This was a simple logic thinko: if we run out of of arguments in one
call and the other call has more arguments, the calls are different.
Tested x86_64-pc-linux-gnu, applied to trunk. This code is not C++0x
specific, but is unlikely to be exercised by non-C++0x code.
2010-02-12 Jason Merrill <jason@redhat.com>
PR c++/43054
* tree.c (cp_tree_equal): Correct CALL_EXPR logic.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 678c7dd..d2ab4f0 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2060,7 +2060,9 @@ cp_tree_equal (tree t1, tree t2)
arg2 = next_call_expr_arg (&iter2))
if (!cp_tree_equal (arg1, arg2))
return false;
- return (arg1 || arg2);
+ if (arg1 || arg2)
+ return false;
+ return true;
}
case TARGET_EXPR:
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic99.C b/gcc/testsuite/g++.dg/cpp0x/variadic99.C
new file mode 100644
index 0000000..4572127
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic99.C
@@ -0,0 +1,22 @@
+// PR c++/43054
+// { dg-options "-std=c++0x" }
+
+template<typename R> struct future { };
+
+template<typename Fn, typename... Args>
+ auto
+ async(Fn&& fn, Args&&... args)
+ -> future<decltype(fn(args...))>;
+
+template<typename Fn, typename... Args>
+ auto
+ async(Fn&& fn, Args&&... args)
+ -> future<decltype(fn(args...))>;
+
+int work2(int value);
+
+void work(int value)
+{
+ async(work2, value);
+}
+