Exceptions

It can be argued that the model chosen for the processing of exceptions in C++ (safe local termination, no retry) is not in step with the choice made on the garbage collection issue: the stack is unwound automatically by the system before the control is passed to the catch site, therefore focusing on the low-level disposal of the resources (comparable to performing garbage collection, without respect to possible higher-level semantics bound to the life-cycle of the ownership of the resources).

The problem is that the catcher (to whom the control is eventually passed) is unknown on the throwing site (as the owners of a resource are usually unknown to the resource), which makes it impossible to safely ensure that the exception will indeed be caught (and handled).

The core of the problem is that the catch site is a function invocation, and cannot thus have an identity which could be stored (the function has an address, not the invocation!). Furthermore, the type of a function cannot express its handling of expressions (even using exception specifications: this is not a reason for using them!).


Table of contents
Marc Girod
Last modified: Sat Feb 28 14:30:45 EET 1998