public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102396] [11/12 Regression] ICE when using concepts, in get,  at cp/constraint.cc:2637 since r11-6245-g79f57d5cb070bb02
Date: Fri, 05 Nov 2021 14:01:54 +0000	[thread overview]
Message-ID: <bug-102396-4-KyM45OCMUJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102396-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102396

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #1)
> Likely started with r11-6245-g79f57d5cb070bb02.

Looks like we went from accepting to rejecting this testcase with r11-2774, and
then with r11-6245 we went from rejecting to ICEing (due to a failing
gcc_checking_assert).  In order to fix the ICE, I think we should just remove
the problematic assert.

However, note that the testcase is strictly speaking invalid ever since the
resolution of CWG2369 which changes the point at which we check constraints
during template argument deduction.  We now check constraints sooner, in
particular _before_ checking non-dependent conversions, and this change can
sometimes unexpectedly lead to constraint recursion, see PR100288 and the
related PRs for more detail.  I believe Clang and MSVC accept this testcase
because they don't implement CWG2369.

The workaround is to encode the non-dependent conversion for first parameter of
the recursive constrained operator== into its own constraint:

diff --git a/102396.C b/102396.C
index dbf2258..3fd2816 100644
--- a/102396.C
+++ b/102396.C
@@ -15,10 +15,10 @@ struct S {
     S();
     explicit S(const T &);

-    template <typename U,
+    template <typename V, typename U,
               std::enable_if_t<!is_S<U>, bool> = false>
-    requires std::equality_comparable_with<T, U>
-    friend bool operator==(const S &s, const U &u) { return s.data == u; }
+    requires is_S<V> && std::equality_comparable_with<T, U>
+    friend bool operator==(const V &s, const U &u) { return s.data == u; }
 };

 template <typename T>

*** This bug has been marked as a duplicate of bug 100288 ***

  parent reply	other threads:[~2021-11-05 14:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-18  8:02 [Bug c++/102396] New: ICE when using concepts, in get, at cp/constraint.cc:2637 dangelog at gmail dot com
2021-09-27 12:51 ` [Bug c++/102396] [11/12 Regression] ICE when using concepts, in get, at cp/constraint.cc:2637 since r11-6245-g79f57d5cb070bb02 marxin at gcc dot gnu.org
2021-11-05 13:23 ` rguenth at gcc dot gnu.org
2021-11-05 14:01 ` ppalka at gcc dot gnu.org [this message]
2021-12-09 18:52 ` dangelog at gmail dot com
2021-12-09 18:54 ` dangelog at gmail dot com
2021-12-11 16:13 ` ppalka at gcc dot gnu.org
2021-12-13 16:58 ` dangelog at gmail dot com

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=bug-102396-4-KyM45OCMUJ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).