public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations @ 2011-03-30 17:35 jason at gcc dot gnu.org 2011-08-08 13:56 ` [Bug c++/48370] " jason at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: jason at gcc dot gnu.org @ 2011-03-30 17:35 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48370 Summary: G++ fails to extend reference temporary lifetime in some situations Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: major Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: jason@gcc.gnu.org In addition to the issue described in bug 26714, we fail to extend the temporary lifetime if the reference we're binding to is a subobject: extern "C" void abort(); bool ok; struct A { A(int) { } ~A() { if (!ok) abort(); } }; struct C { const A& ar; }; int main() { C c = { 1 }; ok = true; } This problem is more severe in C++0x, where you can have initializer_list subobjects: // Test that we properly extend the lifetime of the initializer_list // array even if the initializer_list is a subobject. // { dg-options -std=c++0x } // { dg-do run } #include <initializer_list> extern "C" void abort(); bool ok; struct A { A(int) { } ~A() { if (!ok) abort(); } }; typedef std::initializer_list<A> AL; typedef std::initializer_list<AL> AL2; typedef std::initializer_list<AL2> AL3; struct B { AL al; const AL& alr; }; int main() { AL ar[] = {{1,2},{3,4}}; B b = {{5,6},{7,8}}; AL3 al3 = {{{1},{2},{3}}}; ok = true; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48370] G++ fails to extend reference temporary lifetime in some situations 2011-03-30 17:35 [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations jason at gcc dot gnu.org @ 2011-08-08 13:56 ` jason at gcc dot gnu.org 2011-11-04 12:54 ` jason at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: jason at gcc dot gnu.org @ 2011-08-08 13:56 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48370 Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |danny.dyk@tu-dortmund.de --- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-08 13:54:30 UTC --- *** Bug 50015 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48370] G++ fails to extend reference temporary lifetime in some situations 2011-03-30 17:35 [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations jason at gcc dot gnu.org 2011-08-08 13:56 ` [Bug c++/48370] " jason at gcc dot gnu.org @ 2011-11-04 12:54 ` jason at gcc dot gnu.org 2011-11-04 14:46 ` jason at gcc dot gnu.org 2011-11-05 3:28 ` jason at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jason at gcc dot gnu.org @ 2011-11-04 12:54 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48370 --- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-04 12:54:14 UTC --- Author: jason Date: Fri Nov 4 12:54:08 2011 New Revision: 180944 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=180944 Log: 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. Added: trunk/gcc/testsuite/g++.dg/cpp0x/initlist-lifetime1.C trunk/gcc/testsuite/g++.dg/eh/array1.C trunk/gcc/testsuite/g++.dg/init/lifetime1.C trunk/gcc/testsuite/g++.dg/init/ref21.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/decl2.c trunk/gcc/cp/init.c trunk/gcc/cp/mangle.c trunk/gcc/cp/typeck.c trunk/gcc/cp/typeck2.c trunk/gcc/testsuite/ChangeLog trunk/libiberty/ChangeLog trunk/libiberty/cp-demangle.c ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48370] G++ fails to extend reference temporary lifetime in some situations 2011-03-30 17:35 [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations jason at gcc dot gnu.org 2011-08-08 13:56 ` [Bug c++/48370] " jason at gcc dot gnu.org 2011-11-04 12:54 ` jason at gcc dot gnu.org @ 2011-11-04 14:46 ` jason at gcc dot gnu.org 2011-11-05 3:28 ` jason at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jason at gcc dot gnu.org @ 2011-11-04 14:46 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48370 Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED Target Milestone|--- |4.7.0 --- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-04 14:45:48 UTC --- Fixed for 4.7. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/48370] G++ fails to extend reference temporary lifetime in some situations 2011-03-30 17:35 [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations jason at gcc dot gnu.org ` (2 preceding siblings ...) 2011-11-04 14:46 ` jason at gcc dot gnu.org @ 2011-11-05 3:28 ` jason at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jason at gcc dot gnu.org @ 2011-11-05 3:28 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48370 --- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-05 03:28:09 UTC --- Author: jason Date: Sat Nov 5 03:28:05 2011 New Revision: 181001 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181001 Log: PR c++/48370 * decl.c (cp_finish_decl): Run cleanups in the right order. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/init/lifetime1.C ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-05 3:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-03-30 17:35 [Bug c++/48370] New: G++ fails to extend reference temporary lifetime in some situations jason at gcc dot gnu.org 2011-08-08 13:56 ` [Bug c++/48370] " jason at gcc dot gnu.org 2011-11-04 12:54 ` jason at gcc dot gnu.org 2011-11-04 14:46 ` jason at gcc dot gnu.org 2011-11-05 3:28 ` jason at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).