[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 --- Comment #6 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:ad8161e6d7b26d690d90069ae9a129e7ac36892a commit r12-8150-gad8161e6d7b26d690d90069ae9a129e7ac36892a Author: Jason Merrill Date: Wed Apr 13 13:23:08 2022 -0400 c++: NRV and ref-extended temps [PR101442] This issue goes back to r83221, where the cleanup for extended ref temps changed from being unconditional to being tied to the declaration they formed part of the initializer for. The named return value optimization changes the cleanup for the NRV variable to only run on the EH path; we don't want that change to affect temporary cleanups. The perform_member_init change isn't necessary (there 'decl' is a COMPONENT_REF), it's just for consistency. PR c++/101442 gcc/cp/ChangeLog: * decl.cc (cp_finish_decl): Don't pass decl to push_cleanup. * init.cc (perform_member_init): Likewise. * semantics.cc (push_cleanup): Adjust comment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-nrv1.C: New test.
[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 Richard Biener changed: What|Removed |Added Target Milestone|--- |9.5 Priority|P3 |P2
[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 --- Comment #5 from Jonathan Wakely --- Reduced: bool destroyed = false; struct A { A() {} A(const A &) = delete; A =(const A &) = delete; ~A() {destroyed = true;} }; struct B { const A struct string { string(const char*) { } ~string() { } } s; }; B foo() { B ret{ A{}, "" }; return ret; } int main() { { B b = foo(); } if (!destroyed) __builtin_abort(); }
[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 Jonathan Wakely changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #4 from Jonathan Wakely --- The regression happened after r180941 and not after r180959. Almost certainly this one, as it's the only C++ change in the range: commit b25dd954c41bf75d2bc892c7e9114908eaa7d314 Author: Jason Merrill Date: Fri Nov 4 12:54:08 2011 re PR c++/48370 (G++ fails to extend reference temporary lifetime in some situations) PR c++/48370 * call.c (extend_ref_init_temps, extend_ref_init_temps_1): New. (set_up_extended_ref_temp): Use it. Change cleanup parm to VEC. (initialize_reference): Just call convert_like. * decl.c (grok_reference_init): Just call initialize_reference. (build_init_list_var_init): Remove. (check_initializer): Change cleanup parm to VEC. Handle references like other types. Call perform_implicit_conversion instead of build_init_list_var_init. Don't use build_aggr_init for aggregate initialization of arrays. (cp_finish_decl): Change cleanup to VEC. * typeck2.c (store_init_value): Call extend_ref_init_temps. Use build_vec_init for non-constant arrays. * init.c (expand_aggr_init_1): Adjust. (build_vec_init): Avoid re-converting an initializer that's already digested. * mangle.c (mangle_ref_init_variable): Add a discriminator. * cp-tree.h: Adjust. * typeck.c (convert_for_initialization): Adjust. * decl2.c (maybe_emit_vtables): Adjust. From-SVN: r180944
[Bug c++/101442] [9/10/11/12 Regression] Destructor not called for a temporary object, if it's bound to a ref member of an object subject to NRVO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101442 Jonathan Wakely changed: What|Removed |Added Known to work||4.6.4 Known to fail||4.7.4 Summary|Destructor not called for a |[9/10/11/12 Regression] |temporary object, if it's |Destructor not called for a |bound to a ref member of an |temporary object, if it's |object subject to NRVO |bound to a ref member of an ||object subject to NRVO --- Comment #3 from Jonathan Wakely --- Works correctly in GCC 4.6.4 too. I'll bisect.