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<int> 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.