http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57930
Bug ID: 57930 Summary: missing destructor call after thrown exception in C++11 list initialization Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mmehlich at semanticdesigns dot com In the example below, a subobject of type B is constructed but not destructed when an exception is thrown during construction of the enclosing object of type A after subobject of type B has been constructed. 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 &a2 = { { 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 (...) { } }