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 6FCDB3853D50 for ; Fri, 18 Nov 2022 16:52:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6FCDB3853D50 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=1668790378; 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=fxvpatVCDvAG/5nceFWSG8iACGlowkrkPTo0R13d7ak=; b=Pq78xz/UEuKwiVZEV/q9KbauVh19uSmPe/A+BvqDJYQ8EwTxASGOoUkqEWlcIULf7vC0+m PuKAHW/lnGFztvWJT4BN720orG4iiK9uB/oqojRH9baY3CIyO/vZcvCKRFHdwJTju6bpgL UPDapgpC0gsvK3ieajstI7jaIwMS8wI= 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-64-TWbEx-1ANS6oyLY0yA_txw-1; Fri, 18 Nov 2022 11:52:56 -0500 X-MC-Unique: TWbEx-1ANS6oyLY0yA_txw-1 Received: by mail-qt1-f199.google.com with SMTP id y8-20020ac87088000000b003a528a5b844so5380365qto.18 for ; Fri, 18 Nov 2022 08:52:56 -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=fxvpatVCDvAG/5nceFWSG8iACGlowkrkPTo0R13d7ak=; b=ghgjk/i7mS4cmp1HGDXHAyM17OU7psUoeXJp+ffY8imkplfsXb53Y347/yN+Z/H4wf N4q46lSDLxkHtP25jR4MkkRYJ/MTGoQZzPCg+bVrVzIFQ8jXF5PAoFDSByVFCNcu1JPu eAV8YoUYQyXAbTs82Y9qWCvkarBJyhMEA5MIKpeaEaOmKDkP2jh78xFVIS3uMAciGKkI Iv1u0ckdfDf1dGyULI/1eY7yBS16pmT/4622qWsDSHhHNkIP4fBDHmjSw3xF4fJlonMP PQq9jRNBGuhQP65rh8qlSc1gqjeA/z2BbySsnCxQynoDGkUievPmTduCTCMjbKb5hhcw hkfQ== X-Gm-Message-State: ANoB5pknInZj3RIZdmvBqF4+/xQVpk3RSZkUIbHvvdC9onM8i5JHCkPT a5hXTurX954cci8H/qUy1ktUFHiC1xm7pkiWls0EFiKvgw2l3yoX3Huh2KDmCnjt53aZAiQWSNZ dw6Gz/a3fDIs1a5gWGg== X-Received: by 2002:ac8:1416:0:b0:3a5:6822:1a42 with SMTP id k22-20020ac81416000000b003a568221a42mr7567755qtj.174.1668790376360; Fri, 18 Nov 2022 08:52:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7hwNj7YOWN92UFPOpc9qQcM219PLphabTXSQiZ7BdXoiM3u9xnDNU6u2dUoh0m7cUjELQQBw== X-Received: by 2002:ac8:1416:0:b0:3a5:6822:1a42 with SMTP id k22-20020ac81416000000b003a568221a42mr7567739qtj.174.1668790376086; Fri, 18 Nov 2022 08:52:56 -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 fv11-20020a05622a4a0b00b003a526675c07sm2275992qtb.52.2022.11.18.08.52.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Nov 2022 08:52:55 -0800 (PST) Message-ID: <70af3dc3-33e1-e0c3-b9fc-556f86616a6a@redhat.com> Date: Fri, 18 Nov 2022 11:52:54 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] c++, v4: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions To: Jakub Jelinek Cc: Marek Polacek , Jonathan Wakely , gcc-patches@gcc.gnu.org References: <740b5e1e-7143-c291-5594-af937867fbc3@redhat.com> <529c47ee-b6ff-b5dd-8d4b-1844c46ddbd6@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/18/22 11:34, Jakub Jelinek wrote: > On Fri, Nov 18, 2022 at 11:24:45AM -0500, Jason Merrill wrote: >>> Right, that's the C++17 implicit constexpr for lambdas, finish_function: >>> >>> /* Lambda closure members are implicitly constexpr if possible. */ >>> if (cxx_dialect >= cxx17 >>> && LAMBDA_TYPE_P (CP_DECL_CONTEXT (fndecl))) >>> DECL_DECLARED_CONSTEXPR_P (fndecl) >>> = ((processing_template_decl >>> || is_valid_constexpr_fn (fndecl, /*complain*/false)) >>> && potential_constant_expression (DECL_SAVED_TREE (fndecl))); >> >> Yeah, I guess potential_constant_expression needs to be stricter in a >> lambda. Or perhaps any function that isn't already >> DECL_DECLARED_CONSTEXPR_P? > > potential_constant_expression can't be relied on that it catches up > everything if it, even a simple if statement with a condition not yet > known to be 0 or non-0 results in just a requirement that at least > one of the substatements is potential constant, etc. > Similarly switch statements etc. > If there is a way to distinguish between functions with user > specified constexpr/consteval and DECL_DECLARED_CONSTEXPR_P set > through the above if condition, sure, cp_finish_decl -> > check_static_in_constexpr could be perhaps silent about those, but then > we want to diagnose it during constexpr evaluation at least. But in that > case having it a pedwarn rather than "this is a constant expression" > vs. "this is not a constant expression, if !ctx->quiet emit an error" > is something I don't see how to handle. Because something needs > to be returned, it is a constant expression or it is not. True. Let's go with your option 2, then, thanks. Jason