Re: exceptions in g++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1 September 2011 17:53, Miles Bader wrote:
> Am I on crack, or should the following print "destroyed!" before being
> terminated by the uncaught exception?

It's implementation-defined.

The C++11 standard says:
"If no matching handler is found, the function std::terminate() is
called; whether or not the stack is
unwound before this call to std::terminate() is implementation-defined (15.5.1)."

This allows a core file to be generated immediately, at the point
where the unhandled exception is thrown, which is much more useful for
debugging unhandled exceptions.

If you want to ensure the stack is unwound, put a catch(...) block in
main (and rethrow if you don't want to do anything else)

int main () {
  try { f (); } catch(...) { throw; }
}



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux