From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 3B66538555AF for ; Thu, 20 Jul 2023 18:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B66538555AF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689878234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kqXhlkJQAGIyE8OBK3M7dfOl6ldSI6hC6RDrPO3eKRk=; b=Vx3MxVa8jQ7vzl+kvNpYMNRGWNo/rwIoWArDnDAam2iREv6hmlC7/LXuwr51q0CKNXb0uW ClZLYFm/lcWO0CuWuto9rg4AKCbD1lfa3qak6wqVMCXFIpjpygw+QwhoOXQRLYJDuH8I3W RtSsa/QYuGTQDaTY/FJnvCH1X5LFMak= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-Dq_R2FA4Nq2-jV9hnL1LSA-1; Thu, 20 Jul 2023 14:37:12 -0400 X-MC-Unique: Dq_R2FA4Nq2-jV9hnL1LSA-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-76843c4b0f3so137806885a.2 for ; Thu, 20 Jul 2023 11:37:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689878230; x=1690483030; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kqXhlkJQAGIyE8OBK3M7dfOl6ldSI6hC6RDrPO3eKRk=; b=SbqIRsjoDVo1+yg0KnG0c8rjXN3OSg60V/pLXKRy/UNqje1ygROrwgQxv0DeMQ2oBR s4OW3mwwhIMPkhZWHrqQLkT7U3s445TRBoh7K+KfN5dk+HlFjOHBjRjiodTNWDoXCyix D+aP2ZbkyhExeoB44sMUZAurm7Qrw0MvGmaY6COH58gRk7Redb7AKkbFCiagHykJDC3B 2K6V0YF77O6Cn87kAMsHdAkqORmQ1v4CBpl86KOZKKFDLnZ9uZ7ewIWeQo0gW+4xy/7z EI9cCioIPUYP6uDN9K+DTs0ftcT7c00qmkpUJT1ABx80vz4SPLkps+boH0Xl3Wm7QMsQ hS/Q== X-Gm-Message-State: ABy/qLaIgwdiw6b++qSgwigiEsuT7cBIh6EZFmSJnYMY5l5BD56atlHq A9v6GzLE5H6LOR2GWit4hWI0uOlXniocCmW4s7BWlHugkKmgDUUspMLpWUIHc5n5OleYXEwMW0s fPb7DzApbdBcAQKuiC9Guu9v8Wg== X-Received: by 2002:a05:620a:258a:b0:767:205b:7f4b with SMTP id x10-20020a05620a258a00b00767205b7f4bmr6511565qko.41.1689878230046; Thu, 20 Jul 2023 11:37:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlE3yW+kJ/OxwnCghtqrqcweMPbEP90bVC9COnJ7fZxoFJHrsNOM+lrynXMqdBPZNdhlVJXvyg== X-Received: by 2002:a05:620a:258a:b0:767:205b:7f4b with SMTP id x10-20020a05620a258a00b00767205b7f4bmr6511553qko.41.1689878229775; Thu, 20 Jul 2023 11:37:09 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id c6-20020ae9e206000000b00767d8e12ce3sm536573qkc.49.2023.07.20.11.37.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jul 2023 11:37:08 -0700 (PDT) Message-ID: <03d798a6-0951-1d11-5ae4-476e85f5636e@redhat.com> Date: Thu, 20 Jul 2023 14:37:07 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] c++: fix ICE with is_really_empty_class [PR110106] To: Marek Polacek , Patrick Palka Cc: GCC Patches References: <20230718211458.858343-1-polacek@redhat.com> <7007162f-c356-cbde-575e-1cbbd545323d@idea> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,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 List-Id: On 7/20/23 14:13, Marek Polacek wrote: > On Wed, Jul 19, 2023 at 10:11:27AM -0400, Patrick Palka wrote: >> On Tue, 18 Jul 2023, Marek Polacek via Gcc-patches wrote: >> >>> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk and branches? >> >> Looks reasonable to me. > > Thanks. > >> Though I wonder if we could also fix this by not checking potentiality >> at all in this case? The problematic call to is_rvalue_constant_expression >> happens from cp_parser_constant_expression with 'allow_non_constant' != 0 >> and with 'non_constant_p' being a dummy out argument that comes from >> cp_parser_functional_cast, so the result of is_rvalue_constant_expression >> is effectively unused in this case, and we should be able to safely elide >> it when 'allow_non_constant && non_constant_p == nullptr'. > > Sounds plausible. I think my patch could be applied first since it > removes a tiny bit of code, then I can hopefully remove the flag below, > then maybe go back and optimize the call to is_rvalue_constant_expression. > Does that sound sensible? > >> Relatedly, ISTM the member cp_parser::non_integral_constant_expression_p >> is also effectively unused and could be removed? > > It looks that way. Seems it's only used in cp_parser_constant_expression: > 10806 if (allow_non_constant_p) > 10807 *non_constant_p = parser->non_integral_constant_expression_p; > but that could be easily replaced by a local var. I'd be happy to see if > we can actually do away with it. (I wonder why it was introduced and when > it actually stopped being useful.) It was for the C++98 notion of constant-expression, which was more of a parser-level notion, and has been supplanted by the C++11 version. I'm happy to remove it, and therefore remove the is_rvalue_constant_expression call. >>> -- >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 >>> >>> 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) There shouldn't be a problem completing the type here, so it seems to me that we're missing a call to complete_type_p, at least when !processing_template_decl. Probably need to move the dependent_type_p check up as a result. Jason