diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-01-25 10:15:24 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-01-25 10:15:24 +0100 |
commit | ce268ca2a923f8f35cc9dd5a7d0468a3980f129f (patch) | |
tree | c8247068827c7c516ad9bfb83c7b3677f13bffd1 /gcc/c/c-parser.cc | |
parent | d0acb7b2b26d4f821968043eafd286a1a3a37ca3 (diff) | |
download | gcc-ce268ca2a923f8f35cc9dd5a7d0468a3980f129f.zip gcc-ce268ca2a923f8f35cc9dd5a7d0468a3980f129f.tar.gz gcc-ce268ca2a923f8f35cc9dd5a7d0468a3980f129f.tar.bz2 |
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 <jakub@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.
Diffstat (limited to 'gcc/c/c-parser.cc')
0 files changed, 0 insertions, 0 deletions