On Thu, 10 Jun 2021 at 11:34, Jakub Jelinek wrote: > > On Thu, Jun 10, 2021 at 11:24:43AM +0100, Jonathan Wakely wrote: > > > And I'm not changing the libstdc++ side, where perhaps we could change > > > std::is_constant_evaluated definition for > > > #ifdef __cpp_if_consteval > > > case to if consteval { return true; } else { return false; } > > > but we need to keep it defined to __builtin_is_constant_evaluated () > > > for C++20 or older. > > > > Is there any advantage to changing that (cheaper for GCC to evaluate?) > > I guess compile-time lost in the noise. > > > or should we just continue to use the __builtin unconditionally? > > > > I suppose it's theoretically possible that there could be a non-GCC > > compiler where defined(__cpp_if_consteval) is true but > > __has_builtin(__builtin_is_constant_evaluated) is false. > > Up to you. The wording says Equivalent to > if consteval { return true; } else { return false; } > and return __builtin_is_constant_evaluated (); is equivalent to that. > > Perhaps some people could appreciate to see it literally there, but we
Those people can write their own pure-C++23 library then ;-) > can't use it for C++20 (due to the -Wpedantic warnings or -pedantic-errors Yeah. > errors) and for C++17 and earlier (consteval is not a keyword). std::is_constant_evaluated isn't defined for C++17 and earlier, so in C++14 and C++17 code we have to use the builtin directly (and for C++11 constexpr is so limited that there are no uses for it). I think we should just leave it as-is, and revisit if a good reason arises in future.