From patchwork Thu Mar 16 16:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1757963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iQTzfDU2; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PctWH3kNLz1yWs for ; Fri, 17 Mar 2023 03:48:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E88D385840E for ; Thu, 16 Mar 2023 16:48:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E88D385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678985321; bh=mYaqUCPhGVVfxqHItK4r4/zVm8GjD3HDvRUHKbVtq6A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iQTzfDU2VojLC8JsLpv5l59ylYJg7YYfW3pCXSrk0eqV/4mzwqZPAjiD+v451o5hU LIWzOZPMSO6vpLshCm/DtstAqlYgJq4wHnSB0Rgnznz5b8ebd+Y4ZVY+xIeFP+x6NA Wh0FANDPIQ24TtEdveqsSPBaUTzrBLwLfdt9WbdM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5F6253858C78 for ; Thu, 16 Mar 2023 16:48:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F6253858C78 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-571-qvaFOObyNpWcav5E18LImQ-1; Thu, 16 Mar 2023 12:48:20 -0400 X-MC-Unique: qvaFOObyNpWcav5E18LImQ-1 Received: by mail-qk1-f199.google.com with SMTP id e14-20020a05620a208e00b0074270b9960dso1228596qka.22 for ; Thu, 16 Mar 2023 09:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678985299; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mYaqUCPhGVVfxqHItK4r4/zVm8GjD3HDvRUHKbVtq6A=; b=qjUbgFCvnmsk7wXNgNMHucy90R3QDSf+9d7HMvUIXHfGIj293hwaLfDMCpA2KXr8mu kSr1U1o8UjNiX4NZL4dzsRaqlHyq+WaGQhQIZGcNST+99ntLgmpS2tY2PbkVmfD0NprQ uXeY72rRgkczTxnUPx94JA3JoLu3JqytZSLWwT+BMytl/B69aFodSfnXqZ/wNZPzzMkP N4Pp5w3Hb3sXdTgqTdEkCnL6C5KmX3QqBf1f5YhB6zVQ0jqaRDl737LpTwfKgeXhCIb6 fu6if0C9xFGparSu0P6G4mJViqboE0US2h+rmKG+8fLWVy/ankqiOC9J5bOtH1nlkyBP QRJQ== X-Gm-Message-State: AO0yUKWGKHRq/JPwGvOMsE7pd4wQdzakMNkvKIDkQDX2CktVr3+d6etA UT0V5WiOaj1Hue1LQ/V/i+42RSDdhLCFrEm/rbjjvJ+5l/FCwAV0YONCo3q5AVNn7oRHJ9a4fbX o9qhhK3Yw6qX7JbENr3l65ejJDHgVLZo5sBwZXfVZxh/GrD/l4n8zX65a8Sb40PE7as4hCsfsAK U= X-Received: by 2002:ac8:7dca:0:b0:3a8:e35:258f with SMTP id c10-20020ac87dca000000b003a80e35258fmr8138556qte.31.1678985299466; Thu, 16 Mar 2023 09:48:19 -0700 (PDT) X-Google-Smtp-Source: AK7set9uY3FsOz4OBJoUuZJlK3Hxv3gJpH9W1xNEScOV0cdaMIT2SjOmqjd0A5alEqObLY6TozTsSA== X-Received: by 2002:ac8:7dca:0:b0:3a8:e35:258f with SMTP id c10-20020ac87dca000000b003a80e35258fmr8138514qte.31.1678985299069; Thu, 16 Mar 2023 09:48:19 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id s67-20020a372c46000000b0073b8745fd39sm6143457qkh.110.2023.03.16.09.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 09:48:18 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: ICE with diagnosed constraint recursion [PR100288] Date: Thu, 16 Mar 2023 12:48:16 -0400 Message-Id: <20230316164816.2493686-1-ppalka@redhat.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When satisfaction_cache::get detects constraint recursion, it asserts that entry->result is empty. This makes sense when we're initially detecting/diagnosing recursion from the inner recursive call, but aftewards from the outer recursive call the recursion error is treated like any other SFINAE error encountered during satisfaction, and we set entry->result to whatever the satisfaction value ended up being. Perhaps we should keep entry->result cleared in this case, but that'd require the inner recursive call to communicate to the outer recursive call that constraint recursion occurred, likely via setting entry->result to some sentinel value, which doesn't seem to be worth the complexity. So this patch just relaxes the problematic assert to accept non-empty entry->result as long as we've already issued an error. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? Backports seems unnecessary as the problematic assert is a checking assert. PR c++/100288 gcc/cp/ChangeLog: * constraint.cc (satisfaction_cache::get): Relax overly strict checking assert in the constraint recursion case. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-recursive-sat5.C: New test. --- gcc/cp/constraint.cc | 2 +- .../g++.dg/cpp2a/concepts-recursive-sat5.C | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-recursive-sat5.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index a28c85178fe..273d15ab097 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2705,7 +2705,7 @@ satisfaction_cache::get () if (entry->evaluating) { /* If we get here, it means satisfaction is self-recursive. */ - gcc_checking_assert (!entry->result); + gcc_checking_assert (!entry->result || seen_error ()); if (info.noisy ()) error_at (EXPR_LOCATION (ATOMIC_CONSTR_EXPR (entry->atom)), "satisfaction of atomic constraint %qE depends on itself", diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-recursive-sat5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-recursive-sat5.C new file mode 100644 index 00000000000..b7a02815db9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-recursive-sat5.C @@ -0,0 +1,13 @@ +// PR c++/100288 +// { dg-do compile { target c++20 } } + +class A { }; + +template concept pipeable = requires(A a, T t) { a | t; }; // { dg-error "depends on itself" } + +template void operator|(A, T); + +void f(A tab) { + tab | 1; // { dg-error "no match" } + tab | 1; // { dg-error "no match" } +}