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 78E013858414 for ; Wed, 11 Oct 2023 20:42:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78E013858414 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=1697056953; 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: in-reply-to:in-reply-to:references:references; bh=29JlptVWIGNQaW0LLw4Qp3ro5F06mlBF3Q54b0gSFOM=; b=OkunfDap7CPr59htLe5bLrVjMZBD7GJ52Zn7T9I/DYILHUqjqpXm3M4p0Mo9rkjmGSVi5H hUULljVeG8LdgFUr8nmgELoHT1Sj5hr20rYI1XkDKoj//Vaao5ub5ukhrIrN2fL8vdAuf0 dvy66htqQBkA3mjy6DTCpth9Pz/8UsI= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-jwXdcFXNMWGWHodS5kCv9w-1; Wed, 11 Oct 2023 16:42:12 -0400 X-MC-Unique: jwXdcFXNMWGWHodS5kCv9w-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-65aff02d602so2449986d6.1 for ; Wed, 11 Oct 2023 13:42:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697056931; x=1697661731; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=29JlptVWIGNQaW0LLw4Qp3ro5F06mlBF3Q54b0gSFOM=; b=eyM8D4K+2feXEE0ngQxR1J3FfblPznJl7oKWaIXKZ1bXwt9vP90d2EEA8K/OkE9J2/ pvFwcRrstd6D1L34nS2w4Rltjhr3ge+w2GGOaU1plXCZyQL7WahlReZBOM11p2AfWBZN 3yfA3y78Ux5/hwHfjxIGLYYJ5vFIPc6fHDxviTRGQZgwh7LuRwte5sSTxmPVQPNHmo62 ut9KPHeVu3Oalbki+s3wdJg2O6e0pAoHLRBxRqjocs3W8ykyYLV31u0TBV2wehD2LBFq Sa+gjtiGA2ZMlTL9qTQLywO6XJnQg28n6Y8l3XHTteAw5CopA6loMkn0ByJcs9XKrU6/ ydig== X-Gm-Message-State: AOJu0YxScSX6mY3QvXyMcYoAvADzaeN73T/Aty7ahf3grzdlR8CiFq0b N/N70Ml5CvvnC33OjjllELqLmpDACEjYc3zLbzpH6BYxoj+SRIv/U3uHG/sxYjtvYvLPo/pmkro 58pQPUw23Vi19t97SlQ== X-Received: by 2002:a05:6214:1545:b0:655:d82d:2fd0 with SMTP id t5-20020a056214154500b00655d82d2fd0mr22489776qvw.21.1697056931558; Wed, 11 Oct 2023 13:42:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5PPTWVlneAc5yxZl06FbQ2/Bya9EIY1p8N+nmlM1P1LfnASp1mR+j0KRy1KBOvNGoa2FQvw== X-Received: by 2002:a05:6214:1545:b0:655:d82d:2fd0 with SMTP id t5-20020a056214154500b00655d82d2fd0mr22489764qvw.21.1697056931253; Wed, 11 Oct 2023 13:42:11 -0700 (PDT) Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id r9-20020a0ccc09000000b0065b08bb01afsm5920895qvk.124.2023.10.11.13.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:42:10 -0700 (PDT) Date: Wed, 11 Oct 2023 16:42:09 -0400 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH v2] c++: implement P2564, consteval needs to propagate up [PR107687] Message-ID: References: <20230823194904.1925591-1-polacek@redhat.com> <974dbde5-e1d8-90dc-a023-df214883403c@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/2.2.9 (2022-11-12) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Tue, Oct 10, 2023 at 01:20:09PM -0400, Marek Polacek wrote: > @@ -3364,6 +3365,13 @@ word as an identifier. You can use the keyword @code{__typeof__} instead. > This option is implied by the strict ISO C++ dialects: @option{-ansi}, > @option{-std=c++98}, @option{-std=c++11}, etc. > > +@opindex fno-immediate-escalation > +@opindex fimmediate-escalation > +@item -fno-immediate-escalation > +Do not enable immediate function escalation whereby certain functions > +can be promoted to consteval, as specified in P2564R3. This option is > +turned on by default; it is only effective in C++20 mode or later. > + > @opindex fimplicit-constexpr > @item -fimplicit-constexpr > Make inline functions implicitly constexpr, if they satisfy the I realized it would be useful to extend this doc text, so now it reads: @opindex fno-immediate-escalation @opindex fimmediate-escalation @item -fno-immediate-escalation Do not enable immediate function escalation whereby certain functions can be promoted to consteval, as specified in P2564R3. For example: @example consteval int id(int i) @{ return i; @} constexpr int f(auto t) @{ return t + id(t); // id causes f to be promoted to consteval @} void g(int i) @{ f (3); @} @end example compiles in C++20: @code{f} is an immediate-escalating function (due to the @code{auto} it is a function template and is declared @code{constexpr}) and @code{id(t)} is an immediate-escalating expression, so @code{f} is promoted to @code{consteval}. Consequently, the call to @code{id(t)} is in an immediate context, so doesn't have to produce a constant (that is the mechanism allowing consteval function composition). However, with @option{-fno-immediate-escalation}, @code{f} is not promoted to @code{consteval}, and since the call to consteval function @code{id(t)} is not a constant expression, the compiler rejects the code. This option is turned on by default; it is only effective in C++20 mode or later.