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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:ab908fdb911d6a337cd02b6018bc74b3a2f99acf

commit r14-11461-gab908fdb911d6a337cd02b6018bc74b3a2f99acf
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Feb 28 15:22:47 2025 +0100

    c++: Fix cxx_eval_store_expression {REAL,IMAG}PART_EXPR handling [PR119045]

    I've added the asserts that probe == target because {REAL,IMAG}PART_EXPR
    always implies a scalar type and so applying ARRAY_REF/COMPONENT_REF
    etc. on it further doesn't make sense and the later code relies on it
    to be the last one in refs array.  But as the following testcase shows,
    we can fail those assertions in case there is a reference or pointer
    to the __real__ or __imag__ part, in that case we just evaluate the
    constant expression and so probe won't be the same as target.
    That case doesn't push anything into the refs array though.

    The following patch changes those asserts to verify that refs is still
    empty, which fixes it.

    2025-02-28  Jakub Jelinek  <ja...@redhat.com>

            PR c++/119045
            * constexpr.cc (cxx_eval_store_expression) <case REALPART_EXPR>:
            Assert that refs->is_empty () rather than probe == target.
            (cxx_eval_store_expression) <case IMAGPART_EXPR>: Likewise.

            * g++.dg/cpp1y/constexpr-complex2.C: New test.

    (cherry picked from commit 7eb8ec1856f71b039d1c2235b1c941934fa28e22)

Reply via email to