#include struct Test { public: // --- ctor/dtor --- Test() { ++counter_; } ~Test() { -- counter_; } Test(const Test&) { ++counter_; } public: // --- static members --- static int counter_; }; int Test::counter_ = 0; // Called by foo extern "C" void bar() { Test t; try { Test t; throw 5; } catch (...) { Test t; throw; } } // External C function, which calls bar() and // doens't contain C++ exception handling code. // libgcc can't handle this, but libunwind can. extern "C" void foo(); int main() { try { Test t; foo(); } catch (int) { // Dtor of all Test-object has to be called. assert(Test::counter_ == 0); return Test::counter_; } catch (...) { // An int was thrown - we should not get here. assert(false); return 1; } assert(false); return 1; }