https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115583
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:9662299593c0b028e5008def72744732da429e9f commit r14-10518-g9662299593c0b028e5008def72744732da429e9f Author: Jason Merrill <ja...@redhat.com> Date: Sat Jul 27 16:40:02 2024 -0400 c++: if consteval and consteval propagation [PR115583] During speculative constant folding of an if consteval, we take the false branch, but the true branch is an immediate function context, so we don't want to to cp_fold_immediate it. So we could check IF_STMT_CONSTEVAL_P here. But beyond that, we don't want to do this inside a call, only when first parsing a function. PR c++/115583 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_conditional_expression): Don't cp_fold_immediate for if consteval. gcc/testsuite/ChangeLog: * g++.dg/cpp23/consteval-if13.C: New test. (cherry picked from commit d5f1948640815a554d106542c2e91e4e117aa3bc)