http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58107
Bug ID: 58107 Summary: missing destructor call after thrown exception in lambda capture 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 Code: extern "C" int printf(const char *,...); struct A { A() { printf("A()\n"); } A(const A&) { printf("A(const A&)\n"); } ~A() { printf("~A()\n"); } operator int() const; }; struct B { B() { printf("B()\n"); } B(const B&) { printf("B(const B&)\n"); } ~B() { printf("~B()\n"); } operator int() const; }; int main() { A a; B b; try { auto lll ( [a,c = (throw 7, 9),b]()->int { return a+c+b; } ); // gcc doesn't destroy copy-captured a... } catch (...) { } }; Compile command line: gcc -std=c++1y lambda.cpp -lstdc++ Actual output: A() B() A(const A&) ~B() ~A() Expected output: A() B() A(const A&) ~A() ~B() ~A() The destructor call for the copy captured a is missing.