From 842562b4e1bdd7a7f98e6dcf352b86f96a4e0426 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 23 Mar 2017 14:23:25 -0400 Subject: [PATCH] PR c++/80150 - ICE with overloaded variadic deduction. * pt.c (try_one_overload): Remove asserts. From-SVN: r246422 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 7 ++++--- gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 22b7dfae028..73a25f3f3cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-03-23 Jason Merrill + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a4bf890dbfb..5259dad72a0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..45f4d636c45 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-unify-3.C @@ -0,0 +1,20 @@ +// PR c++/80150 +// { dg-do compile { target c++11 } } + +template +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(foo, foo, a); +} -- 2.30.2