From patchwork Tue Jul 18 21:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 122225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2014003vqt; Tue, 18 Jul 2023 14:16:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHVk7gbuOhhC0uqHL/jrOoNekIYBYw1F70ZVqIfZK6ZuEEog5hZ1du0zGmBh5h6KPwYJnb X-Received: by 2002:a05:6512:4011:b0:4f8:5e49:c610 with SMTP id br17-20020a056512401100b004f85e49c610mr11713067lfb.35.1689714967306; Tue, 18 Jul 2023 14:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689714967; cv=none; d=google.com; s=arc-20160816; b=XRRb311zlMnSanAZOoYoYWbhH7oHmfEUZKUZIb5eSFUKd3tYDSalbDfCSklL4kcSIZ a3E6W60/gL18UI8dFYIPZRLdnyNQry+FzaL5EHR8kazhg0pT+u8lS60f+b1BgGUqyUcI ItxiPO4I12XlY6HKGTh+hZoAdYnATRcqSLmBg+H3n8PR/wZuomP6f/I3ipipWksIUq0k UhtzkIpeHBA28MRPW0aR+Xgg/25GxTyExbtjRISpS2MKZSUi0w3n9BeeGMBqttf8wL+x LB/H7eFkAlMo/78ZnjFkqwwFZEP5mfNdcPv1aMlBsXeFXt9HayJywU6dQM1xiy42UJXz vaHw== 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:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+4RPT/J5Iiwthp2+O4f98SEsVEjv2zQ5ANLxwN4RW9Q=; fh=1drzuSgAqPtVUclta6Ecfzgh/wYNtWpRJF7yhohVT0I=; b=JHKTuEeoNtbmynyR1ALQ+eKB5qR7zpPfQTYy9CR5map7/eaD5faae63ItkjDcgrYrM Y+lhIIBcONnWXziPO3STm/NhRbfuJZzX3MtwQ5sfDY/QS7+9v3QLZSvTel4eEPyNEHSG c3D+2rmZ4IEFvdxDvF2trlf4uZB9QLw7XI8UclITnNE4pT9/LKutJnt1byyW1gshAYkd eo7AA6jtb9KZNcx6lw6EUOnNKoTpRK1t1nXbY63bSdH8bapHa3BCh3gtUJFeg/DFb7X4 RN4iXUAMnwww9pKltHMVdPV5doanKcy3yXNk9vkUdTnazKgpGVR5WYo8NyA/l/EyhPdH VYBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="uO/nduGA"; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m25-20020aa7d359000000b0051e2549c505si1862157edr.112.2023.07.18.14.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 14:16:07 -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="uO/nduGA"; 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 D4FAB3856951 for ; Tue, 18 Jul 2023 21:16:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4FAB3856951 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689714965; bh=+4RPT/J5Iiwthp2+O4f98SEsVEjv2zQ5ANLxwN4RW9Q=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uO/nduGA+2JUsULRt4x5uCWUVP+L7Y/uCWMZiEG5w+nxwDwlxnuJmVLegG2f1Bvxd T5w9d1athwP3mpIriiZ9i30B7ntjADr0MU6V1SLTYZqzTlGYGGAgYJeb77qfzI/H/5 y1Qc+RtvNbeb1RRf6UPG2U2H3NUZ0YNr15W+gQKc= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 38FA43858D32 for ; Tue, 18 Jul 2023 21:15:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38FA43858D32 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-206-UCLXFXjLPyO0IwRTxZSSEA-1; Tue, 18 Jul 2023 17:15:03 -0400 X-MC-Unique: UCLXFXjLPyO0IwRTxZSSEA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A73E68F1849 for ; Tue, 18 Jul 2023 21:15:03 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.10.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 859AD1121314; Tue, 18 Jul 2023 21:15:03 +0000 (UTC) To: GCC Patches , Jason Merrill Subject: [PATCH] c++: fix ICE with is_really_empty_class [PR110106] Date: Tue, 18 Jul 2023 17:14:58 -0400 Message-ID: <20230718211458.858343-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771794561555441162 X-GMAIL-MSGID: 1771794561555441162 Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk and branches? -- >8 -- is_really_empty_class is liable to crash when it gets an incomplete or dependent type. Since r11-557, we pass the yet-uninstantiated class type S<0> of the PARM_DECL s to is_really_empty_class -- because of the potential_rvalue_constant_expression -> is_rvalue_constant_expression change in cp_parser_constant_expression. Here we're not parsing a template so we did not check COMPLETE_TYPE_P as we should. PR c++/110106 gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1): Check COMPLETE_TYPE_P even when !processing_template_decl. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept80.C: New test. --- gcc/cp/constexpr.cc | 2 +- gcc/testsuite/g++.dg/cpp0x/noexcept80.C | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept80.C base-commit: fca089e8a47314a40ad93527ba9f9d0d374b3afb diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 6e8f1c2b61e..1f59c5472fb 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -9116,7 +9116,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (now && want_rval) { tree type = TREE_TYPE (t); - if ((processing_template_decl && !COMPLETE_TYPE_P (type)) + if (!COMPLETE_TYPE_P (type) || dependent_type_p (type) || is_really_empty_class (type, /*ignore_vptr*/false)) /* An empty class has no data to read. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept80.C b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C new file mode 100644 index 00000000000..3e90af747e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C @@ -0,0 +1,12 @@ +// PR c++/110106 +// { dg-do compile { target c++11 } } + +template struct S +{ +}; + +struct G { + G(S<0>); +}; + +void y(S<0> s) noexcept(noexcept(G{s}));