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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:96572464234a88949ebfc07207ae2ae04c63e53b

commit r15-7762-g96572464234a88949ebfc07207ae2ae04c63e53b
Author: Marek Polacek <pola...@redhat.com>
Date:   Tue Feb 18 12:18:31 2025 -0500

    c++: fix rejects-valid and ICE with constexpr NSDMI [PR110822]

    Since r10-7718 the attached tests produce an ICE in verify_address:

      error: constant not recomputed when 'ADDR_EXPR' changed

    but before that we wrongly rejected the tests with "is not a constant
    expression".  This patch fixes both problems.

    Since r10-7718 replace_decl_r can replace

      {._M_dataplus=&<retval>._M_local_buf, ._M_local_buf=0}

    with

      {._M_dataplus=&HelloWorld._M_local_buf, ._M_local_buf=0}

    The initial &<retval>._M_local_buf was not constant, but since
    HelloWorld is a static VAR_DECL, the resulting &HelloWorld._M_local_buf
    should have been marked as TREE_CONSTANT.  And since we're taking
    its address, the whole thing should be TREE_ADDRESSABLE.

            PR c++/114913
            PR c++/110822

    gcc/cp/ChangeLog:

            * constexpr.cc (replace_decl_r): If we've replaced something
            inside of an ADDR_EXPR, call cxx_mark_addressable and
            recompute_tree_invariant_for_addr_expr on the resulting ADDR_EXPR.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-nsdmi4.C: New test.
            * g++.dg/cpp0x/constexpr-nsdmi5.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to