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

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>:

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

commit r16-3022-gbc42128330c0ea70a015b74b655cb8c48b6a8c06
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Aug 5 15:16:50 2025 -0700

    c++: clobber object on placement new [PR121068]

    My r16-2432 patch addressed the original testcase involving an array of
    scalars, but not this additional testcase involving an array of classes.

    This patch addresses the issue more thoroughly, by having placement new
    first clobber the new object, and improving cxx_eval_store_expression to
    implement initial clobbers as well.

    My earlier attempt to do this clobbered the array as a whole, which broke
    construct_at after the resolution of LWG3436 due to trying to create a
    multidimensional array over the top of a single-dimensional array.  To
    side-step that issue, this patch instead clobbers the individual elements
of
    an array, taking advantage of the earlier change to let that activate the
    array member of a union.

            PR c++/121068

    gcc/cp/ChangeLog:

            * constexpr.cc (cxx_eval_store_expression): Handle clobbers.
            (potential_constant_expression_1): Handle clobbers more.
            * decl.cc (build_clobber_this): Use INIT_EXPR for initial clobber.
            * init.cc (build_new_1): Clobber on placement new.
            (build_vec_init): Don't clean up after clobber.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp26/constexpr-new5.C: New test.

Reply via email to