diff options
author | Jason Merrill <jason@redhat.com> | 2024-05-03 09:52:46 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-05-03 16:00:02 -0400 |
commit | 8f3afb83c879f1bfa722a963a07c06aaf174ef72 (patch) | |
tree | 3e62425428c0384ea200388eb961bee5442097f8 /gcc/analyzer | |
parent | c943d7b5c40f447b12431df9ad27a47dad95026d (diff) | |
download | gcc-8f3afb83c879f1bfa722a963a07c06aaf174ef72.zip gcc-8f3afb83c879f1bfa722a963a07c06aaf174ef72.tar.gz gcc-8f3afb83c879f1bfa722a963a07c06aaf174ef72.tar.bz2 |
c++: initializer_list<string> and EH [PR114935]
When we initialize an array of a type with a non-trivial destructor, such as
the backing array for the initializer_list, we have a cleanup to destroy any
constructed elements if a later constructor throws. When the array being
created is a variable, the end of that EH region naturally coincides with
the beginning of the EH region for the cleanup for the variable as a whole.
But if the array is a temporary, or a subobject of one, the array cleanup
region lasts for the rest of the full-expression, along with the normal
cleanup for the TARGET_EXPR. As a result, when tata throws we clean it up
twice. Before r14-1705 we avoided this by disabling the array cleanup in
split_nonconstant_init, but after that we don't go through
split_nonconstant_init, so let's handle it in cp_genericize_target_expr.
PR c++/114935
gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_genericize_init): Add flags parm.
(cp_genericize_init_expr): Pass nullptr.
(cp_genericize_target_expr): Handle cleanup flags.
* typeck2.cc (build_disable_temp_cleanup): Factor out of...
(split_nonconstant_init): ...here.
* cp-tree.h (build_disable_temp_cleanup): Declare.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-eh1.C: New test.
Diffstat (limited to 'gcc/analyzer')
0 files changed, 0 insertions, 0 deletions