18.9 STACK UNWINDING

Earlier, we have seen that after catch clause is completed, control goes to statement after try block. Control never returns to position in try block from where the exception is thrown. It requires special treatment by the system in two regards. The first one is related to stack.

Imagine a situation that no exception has occurred. In that case all functions called (even recursively) would have normally returned. It implies that stack would have been in a position where it was just before entering try block. For simplicity let us call it as base level. If exception has occurred, at that time stack may be containing things (variables and return addresses) above the base level. Therefore, it is necessary to unwind the stack, ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.