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 72546396D809 for ; Wed, 16 Nov 2022 20:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72546396D809 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=1668630396; 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=/B224vRF/DvWiBF53tA+tSn/Hl/mg7gz6BEJ+SEN+Pg=; b=LXVBuTZIq9BvnMnc+PrBH2TXOcJ7lU8uhDSQU/3FQJQkVQnTGvoHYBPYvD4EPl842/FpF2 wfGpjaGemZjwGsCoOXvsDtbihCkkLJddpPVfsIbNl4e5GPsbn3Py9m1wdG2DgmkDRmxAbo 3Ug/mLfEBlbywIK1xNReyk0khyssSQI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-282-Om4BIc2PNAaWxkJ0BadfwQ-1; Wed, 16 Nov 2022 15:26:34 -0500 X-MC-Unique: Om4BIc2PNAaWxkJ0BadfwQ-1 Received: by mail-qt1-f199.google.com with SMTP id cj6-20020a05622a258600b003a519d02f59so13892055qtb.5 for ; Wed, 16 Nov 2022 12:26:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/B224vRF/DvWiBF53tA+tSn/Hl/mg7gz6BEJ+SEN+Pg=; b=MJqq3BJ6vNxWyH0ZNK85apXDhpsch8f0bQ5pY7qupRLuZXrcXq6jcD7fZGPQlUzY0T fHP5t3vyup7tNwXFcNwcDNXy2ldG69S2dG9JQuB8fdRSmDzPJCVuGgW2KIksOb5cGOTf ae4vHFD/OxpsiZ7Q7QvrWHISS/WBgEn17mt4+SVscw4Em0/CthjT8+O9fFBEk0cNdXXv JHcWxMspUywGr66lnueJC//zE8jwXU2C9F3AqFqHMYTOfdzfmZRoCf29Uu2rg9OipAQh EfgN9AP39QkJU9YjSFOBJSuehWK+QhI9OPp2XQs3U6vy1aDXrn8xObYdR8nkvDR+yIzy d4AQ== X-Gm-Message-State: ANoB5pkGWuVxGqCwXPIKueAKs07uJRn86ZYD9v/n6JPcnHG6qyFdMBLx cZdbuHAUVkV7zGLkNAzt8zc45BYH1ztNjV00fyiFyN0O2/fxpj1U03pfaTL044oE4u1fjhJvzlk Evmp1euLpO6oq5wvfbQ== X-Received: by 2002:a05:6214:2b97:b0:4b4:61c2:497f with SMTP id kr23-20020a0562142b9700b004b461c2497fmr22341252qvb.126.1668630394441; Wed, 16 Nov 2022 12:26:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf4L+0VjBRWzWS4BW3HKQTFbt38kXkGPD42NtFcf3mJr6e8XMo3dHbw889RAAuh8ESf5NR7etw== X-Received: by 2002:a05:6214:2b97:b0:4b4:61c2:497f with SMTP id kr23-20020a0562142b9700b004b461c2497fmr22341232qvb.126.1668630394125; Wed, 16 Nov 2022 12:26:34 -0800 (PST) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id bl12-20020a05620a1a8c00b006fae7e6204bsm10599658qkb.108.2022.11.16.12.26.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 12:26:33 -0800 (PST) Message-ID: Date: Wed, 16 Nov 2022 15:26:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] c++, v2: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions To: Jakub Jelinek Cc: Jonathan Wakely , gcc-patches@gcc.gnu.org, Marek Polacek References: <016f168b-f143-baff-5f71-c48d4611ae11@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.4 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_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 List-Id: On 11/16/22 09:46, Jakub Jelinek wrote: > On Wed, Nov 16, 2022 at 09:33:27AM -0500, Jason Merrill wrote: >>> and at that point I fear decl_maybe_constant_var_p will not work >>> properly. Shall this hunk be moved somewhere else (cp_finish_decl?) >>> where we can already call it, or do the above in start_decl for >>> cxx_dialect < cxx20 and add a cxx_dialect == cxx20 hunk in cp_finish_decl? >> >> Hmm, I'd expect decl_maybe_constant_var_p to work fine at this point. > > For static constexpr vars sure, but what about > static const where start_decl doesn't know the initializer? > Sure, decl_maybe_constant_var_p will not crash in that case, but > it will return true even if the static const var doesn't have > a constant initializer. Sure, we'd catch that later on when actually > trying to constexpr evaluate the function and hitting there the > spots added for C++23 in potential_constant_expression*/cxx_eval_*, > but it would mean that we don't reject it when nothing calls the functions. > > I meant something like: > constexpr int bar (int x) { if (x) throw 1; return 0; } > constexpr int foo () { static const int a = bar (1); return 0; } > with -std=c++20 IMHO shouldn't be accepted, while in C++23 it should. I'd expect us to reject that in C++20 in potential_constant_expression, but it's a fair point; it is awkward that P2242 wasn't also accepted as a DR. Moving the check from start_decl to cp_finish_decl makes sense to me. Jason