[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 --- Comment #9 from Jonathan Wakely --- The example from PR 57930 isn't fixed either: extern "C" int printf(const char *,...); struct B { B(int,int) { printf("CB %p\n",this); } B(const B&) { printf("const CB %pn\n",this); } B(B&&) { printf("const CB %pn\n",this); } ~B() { printf("B %p\n",this); } }; struct C { int c; int c2; }; struct A { struct B b; struct C c; }; A test() { //const A a1 = { { 1, 2 }, { 3, (throw 9, 4) } } ; // destructor for B called //const A = { { 1, 2 }, { 3, (throw 9, 4) } } ; // destructor for B not called return { { 1, 2 }, { 3, (throw 9, 4) } } ; // destructor for B not called }; int main() { try { test(); } catch (...) { } } This prints: CB 0x7ffd6eac7620 But should be: CB 0x7ffd6eac7620 B 0x7ffd6eac7620
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Jonathan Wakely changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED |--- --- Comment #8 from Jonathan Wakely --- Comment 1 was fixed, but comment 0 was not, this bug is still present on trunk. The example in comment 0 built with ASan shows: = ==6556==ERROR: LeakSanitizer: detected memory leaks Direct leak of 8 byte(s) in 2 object(s) allocated from: #0 0x7ffa9489a340 in operator new(unsigned long) /home/jwakely/src/gcc/gcc/libsanitizer/asan/asan_new_delete.cc:90 #1 0x400ef6 in X::X() /tmp/leak2.cc:6 #2 0x400db1 in main /tmp/leak2.cc:20 #3 0x7ffa93b33f29 in __libc_start_main ../csu/libc-start.c:308 SUMMARY: AddressSanitizer: 8 byte(s) leaked in 2 allocation(s). Possibly a dup of PR 66139
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 --- Comment #7 from Jason Merrill jason at gcc dot gnu.org --- Author: jason Date: Fri Jan 23 16:30:00 2015 New Revision: 220047 URL: https://gcc.gnu.org/viewcvs?rev=220047root=gccview=rev Log: PR c++/64314 PR c++/57510 * typeck2.c (split_nonconstant_init_1): Remove a sub-CONSTRUCTOR that has been completely split out. Added: trunk/gcc/testsuite/g++.dg/init/array38.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck2.c
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 --- Comment #5 from Jason Merrill jason at gcc dot gnu.org --- Author: jason Date: Fri Dec 12 03:48:55 2014 New Revision: 218653 URL: https://gcc.gnu.org/viewcvs?rev=218653root=gccview=rev Log: PR c++/57510 * typeck2.c (split_nonconstant_init_1): Handle arrays here. (store_init_value): Not here. (split_nonconstant_init): Look through TARGET_EXPR. No longer static. * cp-tree.h: Declare split_nonconstant_init. * call.c (set_up_extended_ref_temp): Use split_nonconstant_init. Added: trunk/gcc/testsuite/g++.dg/cpp0x/initlist90.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/typeck2.c
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Jason Merrill jason at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |5.0 --- Comment #6 from Jason Merrill jason at gcc dot gnu.org --- Fixed for GCC 5.
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Jason Merrill jason at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/57510] initializer_list memory leak
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 --- Comment #4 from Tavian Barnes tavianator at gmail dot com --- I have a testing tool that automatically inserts operator new failures, to help test exception safety and check for leaks. This bug causes all kinds of spurious failures that I have to work around, since anything like this vectorstring vec = {some, strings}; leaks memory if the second string constructor fails. Usually it can be worked around like this string arr[] = {some, strings}; but it's still quite annoying. If someone can point me in the right direction or give an outline of how to fix this bug, I'm happy to try and write up a patch myself. Thanks!
[Bug c++/57510] initializer_list memory leak
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added CC||mmehlich at semanticdesigns dot co ||m --- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org --- *** Bug 57930 has been marked as a duplicate of this bug. ***
[Bug c++/57510] initializer_list memory leak
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2013-06-03 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org --- Testcase without memory and random and not requiring valgrind: #include initializer_list struct counter { static int n; counter() { ++n; } counter(const counter) { ++n; } ~counter() { --n; } }; int counter::n = 0; struct X { X () { if (counter::n 1) throw 1; } counter c; }; int main () { try { auto x = { X{}, X{} }; } catch (...) { if ( counter::n != 0 ) throw; } }
[Bug c++/57510] initializer_list memory leak
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57510 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added Keywords||wrong-code Priority|P3 |P2 CC||jason at gcc dot gnu.org --- Comment #2 from Paolo Carlini paolo.carlini at oracle dot com --- Thus I would say wrong code and P2.