FAQ 26.13 How might the exception-handling mechanism cause a program to silently crash?

Of the zillion reasons a program might silently crash, we'll point out two that are related to the C++ exception-handling mechanism.

Possibility 87642: If an exception is thrown but not caught, terminate() is called, which calls abort() by default. The solution is to wrap main() in a try block that has a catch (...) clause (see FAQ 9.10). If that doesn't work, look for a constructor of a file-scope static object that might throw an exception. Another way to handle this problem is to replace the terminate function with one that prints an appropriate message before it calls abort().

Possibility 253375: If an exception is thrown that didn't match anything on the exception specification list, unexpected() is called, which calls terminate() by default, which calls abort() by default. The solution is to replace the behavior of unexpected() with a function that prints an appropriate message (see FAQ 26.11).



C++ FAQs
C Programming FAQs: Frequently Asked Questions
ISBN: 0201845199
EAN: 2147483647
Year: 2005
Pages: 566
Authors: Steve Summit

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net