PR c++/80150 - ICE with overloaded variadic deduction.
authorJason Merrill <jason@redhat.com>
Thu, 23 Mar 2017 18:23:25 +0000 (14:23 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Mar 2017 18:23:25 +0000 (14:23 -0400)
* pt.c (try_one_overload): Remove asserts.

From-SVN: r246422

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C [new file with mode: 0644]

index 22b7dfae028507d2e3579dafdf2a953c08db62fd..73a25f3f3ccedad95483320bab39b2be281f2efd 100644 (file)
@@ -1,5 +1,8 @@
 2017-03-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/80150 - ICE with overloaded variadic deduction.
+       * pt.c (try_one_overload): Remove asserts.
+
        PR c++/77563 - missing ambiguous conversion error.
        * call.c (convert_like_real): Use LOOKUP_IMPLICIT.
 
index a4bf890dbfbed45f3a6bbf113d2252bdf683c1f7..5259dad72a075df76194b7479d6e7a2abebef96b 100644 (file)
@@ -19694,9 +19694,10 @@ try_one_overload (tree tparms,
             is equivalent to the corresponding explicitly specified argument.
             We may have deduced more arguments than were explicitly specified,
             and that's OK.  */
-         gcc_assert (ARGUMENT_PACK_INCOMPLETE_P (oldelt));
-         gcc_assert (ARGUMENT_PACK_ARGS (oldelt)
-                     == ARGUMENT_PACK_EXPLICIT_ARGS (oldelt));
+
+         /* We used to assert ARGUMENT_PACK_INCOMPLETE_P (oldelt) here, but
+            that's wrong if we deduce the same argument pack from multiple
+            function arguments: it's only incomplete the first time.  */
 
          tree explicit_pack = ARGUMENT_PACK_ARGS (oldelt);
          tree deduced_pack = ARGUMENT_PACK_ARGS (elt);
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C
new file mode 100644 (file)
index 0000000..45f4d63
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/80150
+// { dg-do compile { target c++11 } }
+
+template <typename R, typename... Args>
+bool compare_functions(R(*funcA)(Args...), R(*funcB)(Args...), Args... args) {
+  return false;
+}
+
+int foo(int x) {
+  return x;
+}
+
+float foo(float x) {
+ return x;
+}
+
+int main() {
+  int a = 10;
+  compare_functions<int>(foo, foo, a);
+}