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

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

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

commit r13-9584-gc7f51dc49399023830787e5eec18649b5c2fabc5
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sat Jan 25 10:15:24 2025 +0100

    c++: Only destruct elts of array for new expression if exception is thrown
during the initialization [PR117827]

    The following testcase r12-6328, because the elements of the array
    are destructed twice, once when the callee encounters delete[] p;
    and then second time when the exception is thrown.
    The array elts should be only destructed if exception is thrown from
    one of the constructors during the build_vec_init emitted code in case of
    new expressions, but when the new expression completes, it is IMO
    responsibility of user code to delete[] it when it is no longer needed.

    So, the following patch uses the cleanup_flags argument to build_vec_init
    to get notified of the flags that need to be changed when the expression
    is complete and build_disable_temp_cleanup to do the changes.

    2025-01-25  Jakub Jelinek  <ja...@redhat.com>

            PR c++/117827
            * init.cc (build_new_1): Pass address of a make_tree_vector ()
            initialized gc tree vector to build_vec_init and append
            build_disable_temp_cleanup to init_expr from it.

            * g++.dg/init/array66.C: New test.

    (cherry picked from commit ce268ca2a923f8f35cc9dd5a7d0468a3980f129f)

Reply via email to