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 5AC83395A435 for ; Wed, 16 Nov 2022 14:33:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5AC83395A435 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=1668609210; 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=3yPZPBmgmnAkxADY3HqceziDsjBZBR0vUrIH5zLNajc=; b=JZkW0Q63FRgCY4TKCdY0rD+sJ50vlB46gKwNt0K5SvLKCXeF9FcygCRSmeyIajisyHSjRh w3vFcIovgk+dgEJqXFFdRCfovXIc++PcJgtySEyemSYGPvuDX4L842tCQx6gA7j6SLB3gG MGUQ8eYd1VFnEZ9Pj8bs6l4SC2Hybic= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-12-xmC4TtbrOQix3O_uUukkBw-1; Wed, 16 Nov 2022 09:33:29 -0500 X-MC-Unique: xmC4TtbrOQix3O_uUukkBw-1 Received: by mail-qk1-f199.google.com with SMTP id n13-20020a05620a294d00b006cf933c40feso17613722qkp.20 for ; Wed, 16 Nov 2022 06:33:29 -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=3yPZPBmgmnAkxADY3HqceziDsjBZBR0vUrIH5zLNajc=; b=TAJL10sjAxg/DVfracg5s+Gu+QOA7CbLVMle3+H89lITGctGNys+Skl7jn291Q71Na 1LejFGSu+XYI0Uvb15azj2mKJgn/8OgUMnZJZ+l1zNbvJoZWwyJRNMea9khvczToKVpb FSAkv3xTqM6skjYS6iyRdc1OYP4Ziv7xbfx0a3hcirrTAzNmFnBfmsJd+o4ppADuZesa upAJ4Cw9miYgUE2Md9ZwHOxbOcRUEsahlEEzb/bZWtq1jMGGyvFjJdAW8lXIbJfYJTpL oLGiacCCG5YdQfNiodMvaQlEDMn4gYlJpJQYkbTFpPTvhiAeTvcgTW/d0yETcgaytq6n beMg== X-Gm-Message-State: ANoB5pnh7kGWmJFRa+DEjE/87jvzPGZQ1hX6S4a+M7bDDxsnKQBG2vYL L+L2OuIn6QWnXqOaZEh34oksIWwVwATxeHMOCz9CV+VGpVgw8KQ8UtZ//C4vGsgB7PIviXknSro DE/RioeA/RpW43joAGg== X-Received: by 2002:a05:622a:2303:b0:3a5:1be7:3603 with SMTP id ck3-20020a05622a230300b003a51be73603mr21138007qtb.168.1668609209272; Wed, 16 Nov 2022 06:33:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jLwlNkc3zI08nSx+pAAbRttE6AqQGq9mRXC8xx3XDArBfhrx+nqx5D16iFxIZcbErSPKpmQ== X-Received: by 2002:a05:622a:2303:b0:3a5:1be7:3603 with SMTP id ck3-20020a05622a230300b003a51be73603mr21137985qtb.168.1668609208993; Wed, 16 Nov 2022 06:33:28 -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 m22-20020a05620a291600b006fa43e139b5sm10295616qkp.59.2022.11.16.06.33.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 06:33:28 -0800 (PST) Message-ID: <016f168b-f143-baff-5f71-c48d4611ae11@redhat.com> Date: Wed, 16 Nov 2022 09:33:27 -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: 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,KAM_SHORT,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:08, Jakub Jelinek wrote: > On Wed, Nov 16, 2022 at 08:20:34AM -0500, Jason Merrill wrote: >>> Ok. But there is another issue, the >>> https://eel.is/c++draft/expr.const#5.2 >>> spot that P2647R1 is changing didn't exist in C++20, it was only added with >>> P2242R3. So, if one would treat P2647R1 as a DR for C++20, one has to come up with >>> a different standard modification. >>> Probably change the last bullet of: >>> [dcl.constexpr]/3 >>> its function-body shall not enclose >>> >>> a goto statement, >>> an identifier label, >>> a definition of a variable of non-literal type or of static or thread storage duration. >>> to >>> a definition of a variable of non-literal type or of a non-constexpr >>> variable of static or thread storage duration. >>> or so. >> >> Indeed, though the hypothetical C++20 change could still use the "usable in >> constant expressions" phrase. > > Yes. > Though, with -std=c++20 we are rejected already in start_decl's > if (current_function_decl && VAR_P (decl) > && DECL_DECLARED_CONSTEXPR_P (current_function_decl) > && cxx_dialect < cxx23) > { > bool ok = false; > if (CP_DECL_THREAD_LOCAL_P (decl) && !DECL_REALLY_EXTERN (decl)) > error_at (DECL_SOURCE_LOCATION (decl), > "%qD defined % in %qs function only " > "available with %<-std=c++2b%> or %<-std=gnu++2b%>", decl, > DECL_IMMEDIATE_FUNCTION_P (current_function_decl) > ? "consteval" : "constexpr"); > else if (TREE_STATIC (decl)) > error_at (DECL_SOURCE_LOCATION (decl), > "%qD defined % in %qs function only available " > "with %<-std=c++2b%> or %<-std=gnu++2b%>", decl, > DECL_IMMEDIATE_FUNCTION_P (current_function_decl) > ? "consteval" : "constexpr"); > else > ok = true; > if (!ok) > cp_function_chain->invalid_constexpr = true; > } > 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. Jason