Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ANSI/ISO |
C++ only |
#include <exception>
void unexpected(void);
void f() throw() // function may throw no exceptions
{throw "bad"; } // throw calls unexpected()
the
unexpected_handler is the one in effect immediately after evaluating
the throw expression.In a multithreaded environment, if a thread throws an exception that is not listed in its exception specification, then unexpected() is called. The default for unexpected() is to call terminate(), which defaults to calling abort(), which then causes a SIGABRT signal to be generated to the thread issuing the throw. If the SIGABRT signal is not caught, the process is terminated. You can replace the default unexpected() behavior for all threads in the process by using the set_unexpected() function. One possible use of set_unexpected() is to call a function which issues a pthread_exit(). If this is done, a throw of a condition by a thread that is not in the exception specification results in thread termination, but not process termination.
unexpected() returns no values.
Refer to z/OS XL C/C++ Language Reference for more information about z/OS XL C++ exception handling, including the unexpected() function.