https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117321
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Resolution|MOVED |--- Ever confirmed|0 |1 Last reconfirmed| |2024-10-28 Status|RESOLVED |ASSIGNED --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 59473 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59473&action=edit gcc15-pr117321.patch Lightly tested patch. While std::__is_constant_evaluated() is always_inline, at -O0 that just means we inline the setting of some temporary to 0, but it doesn't lead to optimizing away code guarded by it. We need something that is folded to false already in the FE or worst case during the gimplification, which I think both if consteval and if (__builtin_is_constant_evaluated()) guarantee. As GCC predefines __STDCPP_FLOATn_T__ etc. macros only for -std=c++23 or later, I think just using if consteval is enough, the guard is just in case clang does something weird in the future (currently it doesn't support the paper nor predefine __STDCPP_FLOATn_T__).