public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Cc: Andrew Sutton <andrew.n.sutton@gmail.com>
Subject: C++ PATCH for c++/73456 (concepts ICE with constrained parameter pack)
Date: Thu, 11 Aug 2016 15:43:00 -0000	[thread overview]
Message-ID: <CADzB+2ni+VgqDsRSr1n_jU1wnK8GzkVAkTgcYaXkCkEG5TowUg@mail.gmail.com> (raw)

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

In trying to decide if the constraints on the partial specialization
subsume those on the primary template, we consider whether any of the
constraints on the primary template imply the type constraint typename
list<Seqs...>.  We don't have any matching constraints on the primary
template, so we look to see if there are any non-atomic constraints
that we might be able to decompose in order to produce a match.  This
function doesn't know how to handle the pack expansion
Sequence<Seqs>... and so it crashes.

A pack expansion isn't really atomic, but it also won't decompose any
further, so treating it as non-atomic here leads to an infinite loop;
treating it as atomic, as 6.1 did, fixes the testcase.

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

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

commit 5b8341e2a06c9dead76cba2485a2e0633badbac0
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 11 11:15:13 2016 -0400

    	PR c++/73456 - ICE with constrained parameter pack.
    
    	* logic.cc (non_atomic_constraint_p): Handle EXPR_PACK_EXPANSION.

diff --git a/gcc/cp/logic.cc b/gcc/cp/logic.cc
index dda98df..b86e740 100644
--- a/gcc/cp/logic.cc
+++ b/gcc/cp/logic.cc
@@ -305,6 +305,9 @@ non_atomic_constraint_p (tree t)
     case ICONV_CONSTR:
     case DEDUCT_CONSTR:
     case EXCEPT_CONSTR:
+      /* A pack expansion isn't atomic, but it can't decompose to prove an
+	 atom, so it shouldn't cause analyze_atom to return undecided.  */
+    case EXPR_PACK_EXPANSION:
       return false;
     case CHECK_CONSTR:
     case PARM_CONSTR:
diff --git a/gcc/testsuite/g++.dg/concepts/variadic4.C b/gcc/testsuite/g++.dg/concepts/variadic4.C
new file mode 100644
index 0000000..d20fa7d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/variadic4.C
@@ -0,0 +1,20 @@
+// PR c++/73456
+// { dg-options "-std=c++1z -fconcepts" }
+
+template<typename...> struct list {};
+
+template<typename Seq>
+concept bool Sequence = true;
+
+template<Sequence... Seqs>
+struct zip;
+
+template<Sequence... Seqs>
+    requires requires { typename list<Seqs...>; }
+// main.cpp:12:8: internal compiler error: in non_atomic_constraint_p, at cp/logic.cc:315
+struct zip<Seqs...> {};
+
+int main()
+{
+    zip<list<>, list<int>> {};
+}

                 reply	other threads:[~2016-08-11 15:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADzB+2ni+VgqDsRSr1n_jU1wnK8GzkVAkTgcYaXkCkEG5TowUg@mail.gmail.com \
    --to=jason@redhat.com \
    --cc=andrew.n.sutton@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).