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 629323858410 for ; Fri, 21 Jul 2023 17:44:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 629323858410 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=1689961461; 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=FgU3jH0k50VG1AUuC6CiASTJ9OgPTENJ8oMjtqVwXh4=; b=HkFkwb2hs0o+cxSZMUBNtmSGkMfa+GdQ58j5y92YuTjP0gS85AVcCXCxDpevxOecmk4l09 KFkK51mZaEoO/rWCVZ2RyH1q4FHCoWQ25CgWJ/sTA+JsPxLuFzjjKXBanXvejkuCU6hhDV fSzNwOQL+4qPJdeKdXXnKh8TovyGsoY= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-_FpoajeiNyOsIYo4jXDE1g-1; Fri, 21 Jul 2023 13:44:20 -0400 X-MC-Unique: _FpoajeiNyOsIYo4jXDE1g-1 Received: by mail-ua1-f72.google.com with SMTP id a1e0cc1a2514c-7999ef0f37fso535869241.0 for ; Fri, 21 Jul 2023 10:44:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689961460; x=1690566260; 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=FgU3jH0k50VG1AUuC6CiASTJ9OgPTENJ8oMjtqVwXh4=; b=DqSQ1FZg5GKGT7Gg1Dbqclx0bWUuZWraagscGQLRoMjJs6EaFHKKNZZIbBbzoCmTDV Q+4dT9GePVEM7OpT4kjXXcERIEyaJBPERUutam+q52ktV1D3YnzqvGnHdJgCkNxx0MET i50hFcRokiIHKQm0l29MAOb+38e83F/OdlX1foCQ08+9/hG5zwXxPaN3MWzs7yGVfADw lKiileNdNVddHgyiM1mm012my6p6S1s38HHUAxQTc8XEKSUBnHMpyGyH9+UTKVLhpKTz zwNCuBujygO3i8bs0nfCbgLDwkejm5a4eefw+FzT66irUrlIilWlR+2qaYXtVN7gXfxL EO3A== X-Gm-Message-State: ABy/qLYvU3VZYCR+nU93chrhWlHmngpxxTGm4Ri1pPU2opTJykDQeRN5 zy5/TUrbM99ABQUqEW7GvMGcdasuFsCRoT96oQeokWk4VMN34mjnwNh0+vfVV8kWCwMOwaY48By xEoAAgJwJFCBw0iQdPQ== X-Received: by 2002:a67:eb87:0:b0:444:3f97:9a4b with SMTP id e7-20020a67eb87000000b004443f979a4bmr658566vso.29.1689961459951; Fri, 21 Jul 2023 10:44:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBPT0s+BqiLdmy2E2NHaVQGvPig++PtxuV/i0gFmV9Dc+CWvZ2G3AJkUQfVgRo8zhnxoucmg== X-Received: by 2002:a67:eb87:0:b0:444:3f97:9a4b with SMTP id e7-20020a67eb87000000b004443f979a4bmr658553vso.29.1689961459644; Fri, 21 Jul 2023 10:44:19 -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 g2-20020a05620a108200b00767b07ec8adsm1252452qkk.82.2023.07.21.10.44.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jul 2023 10:44:19 -0700 (PDT) Message-ID: <197c642a-a916-5be4-fe9e-2f0710333c92@redhat.com> Date: Fri, 21 Jul 2023 13:44:17 -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 Cc: Patrick Palka , GCC Patches References: <20230718211458.858343-1-polacek@redhat.com> <7007162f-c356-cbde-575e-1cbbd545323d@idea> <03d798a6-0951-1d11-5ae4-476e85f5636e@redhat.com> 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=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 17:58, Marek Polacek wrote: > On Thu, Jul 20, 2023 at 03:51:32PM -0400, Marek Polacek wrote: >> On Thu, Jul 20, 2023 at 02:37:07PM -0400, Jason Merrill wrote: >>> 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. >> >> Wonderful. I'll do that next. > > I found a use of parser->non_integral_constant_expression_p: > finish_id_expression_1 can set it to true which then makes > a difference in cp_parser_constant_expression in C++98. In > cp_parser_constant_expression we set n_i_c_e_p to false, call > cp_parser_assignment_expression in which finish_id_expression_1 > sets n_i_c_e_p to true, then back in cp_parser_constant_expression > we skip the cxx11 block, and set *non_constant_p to true. If I > remove n_i_c_e_p, we lose that. This can be seen in init/array60.C. Sure, we would need to use the C++11 code for C++98 mode, which is likely fine but is more uncertain. It's probably simpler to just ignore n_i_c_e_p for C++11 and up, along with Patrick's suggestion of allowing null non_constant_p with true allow_non_constant_p. Jason