[Bug c++/115583] [14 Regression] C++23: Call to consteval function in `if consteval` immediate function context rejected at -O1 since r14-4140

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jul 29 13:14:33 GMT 2024


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
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:9662299593c0b028e5008def72744732da429e9f

commit r14-10518-g9662299593c0b028e5008def72744732da429e9f
Author: Jason Merrill <jason@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)


More information about the Gcc-bugs mailing list