C++ condition handling semantics

C++ includes the C condition handling model and new C++ constructs throw, try, and catch. For more information about these C++ constructs, see z/OS XL C/C++ Language Reference. If you use C exception handling constructs (signal/raise) in your C++ routine, condition handling will proceed as described in C condition handling semantics. You can use C or C++ condition handling constructs in your C++ applications, but do not mix C constructs with C++ constructs in the same application because undefined behavior could result.

If you use C exception handling, a C++ routine can register a signal handler by coding signal() to handle exceptions raised in either a C or a C++ routine. If you use the C++ exception handling model, only C++ routines can catch a thrown object. When a thrown object is handled by a catch clause, execution will continue after the catch clause in the routine. If a thrown object goes unhandled after each stack frame has had a chance to handle it, C++ defines that the terminate() function is called. By default, terminate() calls abort(). You can call the C++ library function set_terminate() to register your own function to be called by terminate. When terminate() finishes calling the user's function, it will call abort().

C routines do not support try, throw, and catch, nor can C routines use signal() to register a handler for thrown objects. A C++ routine cannot register a handler via signal() to catch thrown objects; it must use catch clauses. try, throw, and catch cannot handle hardware exceptions, nor C, COBOL, PL/I, or Language Environment exceptions.