[Bug c++/105756] [12/13 Regression] ICE in cxx_eval_constant_expression at cp/constexpr.cc:7586: unexpected expression ‘ElemSize’ of kind template_parm_index

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 3 18:59:20 GMT 2022


--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:


commit r13-986-g0ecb6b906f215ec56df1a555139abe9ad95414fb
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jun 3 14:58:22 2022 -0400

    c++: value-dep but not type-dep decltype expr [PR105756]

    Here during ahead of time instantiation of the value-dependent but not
    type-dependent decltype expression (5 % N) == 0, cp_build_binary_op folds
    the operands of the == via cp_fully_fold, which performs speculative
    constexpr evaluation, and from which we crash for (5 % N) due to the

    Since the operand folding performed by cp_build_binary_op appears to
    be solely for sake of diagnosing overflow, and since these diagnostics
    are suppressed when in an unevaluated context, this patch avoids this
    crash by suppressing cp_build_binary_op's operand folding accordingly.

            PR c++/105756


            * typeck.cc (cp_build_binary_op): Don't fold operands
            when c_inhibit_evaluation_warnings.


            * g++.dg/cpp0x/decltype82.C: New test.

More information about the Gcc-bugs mailing list