From patchwork Fri Apr 22 18:36:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1621110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=OJnAS6qC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KlNRf72lWz9s0r for ; Sat, 23 Apr 2022 04:37:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4AEE93856DCF for ; Fri, 22 Apr 2022 18:37:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AEE93856DCF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650652620; bh=XgWf3WiI7Th7r88iMRajJM0KvRWhkRA4Cq0MejXyyH4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OJnAS6qCOZvx/t+azgW+hycKt/9ivTvyAK8FNDfzH4eraKK6mQWYEeZbD4J2MzzNP Yf5pKlqnCCl5XYcKV09gNgL74kJ3lI3gCf46isCabTDE6JZTioBHdMDsWApPcPjnjN iw2OgVz38szTGUAg5tBpEwrkbmsv/r6eVGMmvnIk= 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 EBFF53858C83 for ; Fri, 22 Apr 2022 18:36:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBFF53858C83 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-7mXRFjb1OtOl6ytUESEd3w-1; Fri, 22 Apr 2022 14:36:17 -0400 X-MC-Unique: 7mXRFjb1OtOl6ytUESEd3w-1 Received: by mail-qv1-f69.google.com with SMTP id fw9-20020a056214238900b0043522aa5b81so7233250qvb.21 for ; Fri, 22 Apr 2022 11:36:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XgWf3WiI7Th7r88iMRajJM0KvRWhkRA4Cq0MejXyyH4=; b=OmbFA086ikxO7a1DKk80Mv+IGeUU+e0dxM00TuxrpC3ACHrcEua1FFIeVOKOfgxi4+ 1DGrOSElCYyIa9GISxV62LAQabX9KRVszPpBcDv+/8Atav6foEEYPoJFkSDU53FF0JGg wIdtRhajfF+tiaVA+baLcpDHSMTIwHoudfMLGMplFk+UaMcc8SpUu7kwnLuWQJgcazmt N9+TM3eAZZpD9VupcGiSPKYM4kW7/IdVqpaUtOqAOul20mT6Thp/l1U0cO6lb3QEomJN 1QE+tifSO9W5ecOz0+6DL2ICjsGr6qt0Od2FST1k5IEEdtVZHBUxrweqnnbNhOj6rtS2 LR5g== X-Gm-Message-State: AOAM532tv0hWoNRXgzPaNXAtC7He4lM6gIXJt4/wogyHVzzBU3Slt2Q3 lWVj1AT59UPkrJPNMK0VXRIHIo6H4yjM2+npxHz4F8L2LH+Vzr0JOphjRozpXlLbDZAAlE+UYmF 3w5OhFvWejScH9qOV3aZCGH082k0FMX9n1zPN79W9dNRVBXkkqEf2Ol+qpqNzxpY+J2s= X-Received: by 2002:ac8:5fc4:0:b0:2f1:e898:2973 with SMTP id k4-20020ac85fc4000000b002f1e8982973mr4238462qta.157.1650652577112; Fri, 22 Apr 2022 11:36:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoWMoDy35D4Fex2iR/4PK3RPqicesEYZPve13zR0I9CSHwQTYvFDcara9ih6nzEz1RwKtWXA== X-Received: by 2002:ac8:5fc4:0:b0:2f1:e898:2973 with SMTP id k4-20020ac85fc4000000b002f1e8982973mr4238442qta.157.1650652576817; Fri, 22 Apr 2022 11:36:16 -0700 (PDT) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id bk18-20020a05620a1a1200b00680c72b7bf4sm1282340qkb.93.2022.04.22.11.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:36:16 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: crash with requires-expr and -Wsequence-point [PR105304] Date: Fri, 22 Apr 2022 14:36:10 -0400 Message-Id: <20220422183610.3127561-1-ppalka@redhat.com> X-Mailer: git-send-email 2.36.0.rc2.10.g1ac7422e39 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.6 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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" Here we're crashing from verify_sequence_points for this requires-expr condition because it contains a templated CAST_EXPR with empty operand, and verify_tree doesn't ignore this empty operand only because the manual tail recursion that it perform for unary expression trees skips the NULL test. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for 10/11/trunk? PR c++/105304 gcc/c-family/ChangeLog: * c-common.cc (verify_tree) [restart]: Move up to before the NULL test. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires30.C: New test. --- gcc/c-family/c-common.cc | 2 +- gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 70f55f3a346..bb0544eeaea 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -2009,12 +2009,12 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp, enum tree_code code; enum tree_code_class cl; + restart: /* X may be NULL if it is the operand of an empty statement expression ({ }). */ if (x == NULL) return; - restart: code = TREE_CODE (x); cl = TREE_CODE_CLASS (code); diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C new file mode 100644 index 00000000000..f500af3f616 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires30.C @@ -0,0 +1,10 @@ +// PR c++/105304 +// { dg-do compile { target c++20 } } +// { dg-additional-options "-Wall -Wsequence-point" } + +struct A { }; + +int main() { + if (requires { A(); }) + ; +}