http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58859
Bug ID: 58859 Summary: throwing exceptions in destructors causes std::terminate called too early. Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: meng at g dot clemson.edu the following program does not execute (2) for g++-4.8.[01] -std=c++11 and I think this is a bug. I tested the program on g++-4.[67].[01] with or without c++11 enabled, and g++-4.8.0 with c++11 flag, and in VS 2010, in all these cases, (2) was executed and the program finished without a call to std::terminate. My understanding is that the throw expression happens before stack unwinding and that there is a matching handler, therefore, std::terminate should not be called. ----------------------- BEGIN ----------------------- #include <iostream> struct test_t { test_t () { std::cout << " test_t @ " << this << std::endl; } ~test_t () { std::cout << "~test_t @ " << this << std::endl; throw 0; } }; int main () { try { test_t const t; // (1) } catch (...) { std::cout << __LINE__ << std::endl; // (2) } } ----------------------- END -----------------------