Summary: | Temporary for indirect binding is not destroyed when destructor from initializer temp throws | ||
---|---|---|---|
Product: | gcc | Reporter: | Hubert Tong <hstong> |
Component: | c++ | Assignee: | Jason Merrill <jason> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | daniel.kruegler, jason, webrown.cpp |
Priority: | P3 | Keywords: | wrong-code |
Version: | 4.7.0 | ||
Target Milestone: | 12.0 | ||
See Also: |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66139 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52320 |
||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2022-01-06 00:00:00 |
Description
Hubert Tong
2012-07-06 03:21:38 UTC
(It doesn't matter for 4.7 but you need noexcept(false) on Q::~Q to use the testcase on trunk) clang and GCC both produce the same result while ICC produces the bug reporter expected result. This is also most likely related to PR 66139 and PR 52320. The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:4c6afbbd48f0c40ddf949bc403d9bd5f5e14204f commit r12-6332-g4c6afbbd48f0c40ddf949bc403d9bd5f5e14204f Author: Jason Merrill <jason@redhat.com> Date: Wed Jan 5 11:18:25 2022 -0500 c++: clean up ref-extended temp on throwing dtor [PR53868] We have wrap_temporary_cleanups to handle the EH region nesting problems between cleanups for complete variables and cleanups for temporaries used in their construction, but we weren't calling it for temporaries extended from binding to a reference. We still don't want this for array cleanups (since my PR94041 fix), so I move that exception from initialize_local_var to wrap_temporary_cleanups. PR c++/53868 gcc/cp/ChangeLog: * decl.c (cp_finish_decl): Use wrap_temporary_cleanups for cleanups from set_up_extended_ref_temp. (wrap_temporary_cleanups): Ignore array cleanups. (initialize_local_var): Don't check for array here. * cp-tree.h (BIND_EXPR_VEC_DTOR): New. * init.c (build_vec_delete_1): Set it. gcc/testsuite/ChangeLog: * g++.dg/eh/ref-temp1.C: New test. * g++.dg/eh/ref-temp2.C: New test. Fixed for GCC 12. |