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: 70902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp588269wrt; Thu, 16 Mar 2023 09:49:09 -0700 (PDT) X-Google-Smtp-Source: AK7set8aI8Tcn/BGccznuO5WyepKpwbIzfh1Y7+yaEO67/Nb+QEYDj8aS/bCtl7CDHru0ZTo2kbc X-Received: by 2002:a17:906:980d:b0:881:4d98:fe2e with SMTP id lm13-20020a170906980d00b008814d98fe2emr10286947ejb.29.1678985349125; Thu, 16 Mar 2023 09:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678985349; cv=none; d=google.com; s=arc-20160816; b=sImrZl1n1pWj9R4Mt8MP+/ZDREvmwy7tCWBopPnQ5KHDIjV9uZdZ07avUdTdaoBqpZ q4ZoFNy5Q302fgpkCXxVI4gWhRLSrpijJTe972U7x8ag9GKFrHaI36ebxiYuQIMBp6du Tz1ZGa62Vdlu7UJ0I+ms5+msk3UtIzV345vw8uJQql5pwgmOhktE06owBkSUnzciNB4Q F65raUkRLE2UdUXfRdEmgzO4QYjcjPM1sosyakn8bASJYlGaf9/sZzY8eWC4s2+LFSxi JZfugcjkfGEx4hAYvap7SPJ3E/n1oUhQhiw47HNsjTZ2pXKNH0iVZefs9q91Rik76d5v BJkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mYaqUCPhGVVfxqHItK4r4/zVm8GjD3HDvRUHKbVtq6A=; b=yFi+JIVbh7iRVn+6I83my92E+mKit8FQaX4ViY9jLl7XrUaCf52ab5SINAHF6eag0p 5Lf0bmHD0R++ZJQ53evhFD++4QoTllZ3+t720ScFaHPcKreYrBeKLEx/p+UkPHoWoJzT b11M8naVawislGioycDpjUY6Y5eIszJ6UXgd+3BOLRDTLEWWQo2gvu7iJN4AIJMPUABo i/CzQ6IAwcnFGF8UZb1E6fm/72ATIKM/bgHIuT4maz7LfuofyzcwKLMKEBb2r7NHfFKO oVK7+v4evBzmb9n+wf2sPyGaTKBESjign/5wLRg7iNRMf6VWTcuDksNDYtOm21zPf4gT Li7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="o6ww2eF/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qw41-20020a1709066a2900b009285f242673si6279824ejc.209.2023.03.16.09.49.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 09:49:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="o6ww2eF/"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D85CE385B527 for ; Thu, 16 Mar 2023 16:49:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D85CE385B527 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678985345; 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=o6ww2eF/K2jvxePf8hsl0otjF+2vNiHShRyKjQJ66WbUeEa7YS8pctLHaA8EvZrx0 PZBJwatqAXWu8Wv63K1MigSpDbZ0hwMt2ZhLg2V2GG1AL7tzn3CgVptpslVCNpQlkZ 5DLTmZ4Qa0I2Yz5Oqxj2byk0kcAYp3v6Lo/DFvkY= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760543740952799009?= X-GMAIL-MSGID: =?utf-8?q?1760543740952799009?= 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" } +}