public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/80150, ICE with overloaded variadic deduction
@ 2017-03-23 18:20 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-03-23 18:20 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

This bug is related to 69056, where I implemented deducing a pack that
starts with explicitly specified arguments.  In that patch I added a
sanity check to make sure that when we do that we always start from a
pack marked incomplete.  But this test demonstrates a case where that
check is wrong; if we're deducing the same pack from two different
function arguments, it isn't incomplete the second time, we need to
deduce the same thing we got the first time.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 80150.diff --]
[-- Type: text/plain, Size: 1639 bytes --]

commit c46a927234d00a1723347ca1b21b2509f6513fc9
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 13:29:35 2017 -0400

            PR c++/80150 - ICE with overloaded variadic deduction.
    
            * pt.c (try_one_overload): Remove asserts.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a4bf890..5259dad 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 0000000..45f4d63
--- /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 <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);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-23 18:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 18:20 C++ PATCH for c++/80150, ICE with overloaded variadic deduction Jason Merrill

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).