[Bug c++/123677] [16 Regression] ICE: tree check: expected constructor, have ptrmem_cst in cxx_eval_store_expression, at cp/constexpr.cc since r16-3022

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 21 13:31:03 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123677

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:9abe0b4f76265a062f1646a0bff1f58b70ae5695

commit r16-6954-g9abe0b4f76265a062f1646a0bff1f58b70ae5695
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 21 14:30:03 2026 +0100

    c++: Fix ICE with constant evaluation of a = {CLOBBER} with ptrmemfn
[PR123677]

    The following testcase ICEs when we evaluate a = {CLOBBER} stmt.
    The code assumes that if type is an aggregate type and *valp is
    non-NULL, then it must be a CONSTRUCTOR.
    That is usually the case, but there is one exception, *valp can
    be a PTRMEM_CST if TYPE_PTRMEMFUNC_P (type) and in that
    case CONSTRUCTOR_ELTS (*valp) obviously ICEs or misbehaves.

    Now, while I could do something like
      if (*valp && (!TYPE_PTRMEMFUNC_P (type) || TREE_CODE (*valp) !=
PTRMEM_CST))
    just making sure TREE_CODE (*valp) == CONSTRUCTOR seems much easier
    and more readable.

    2026-01-21  Jakub Jelinek  <jakub@redhat.com>

            PR c++/123677
            * constexpr.cc (cxx_eval_store_expression): Only clear
            CONSTRUCTOR_ELTS (*valp) if *valp is CONSTRUCTOR.

            * g++.dg/cpp2a/pr123677.C: New test.


More information about the Gcc-bugs mailing list