views:

32

answers:

1

On Symbian, if a function exits because of a leave, are the destructors of its local (automatic) variables called?

From what I've tried on the emulator, they are. But then, why use the Cleanup Stack rather then smart pointers?

+3  A: 

Yes, automatic variables are properly destructed. Since (I think) version 9.1 of Symbian OS, leave is implemented using C++ exceptions.

Earlier versions of Symbian did not support exceptions at all, hence the whole cleanup stack mechanism. Automatic variables would not have had their destructors called when leaving.

MathewI
Yes and hence the convention of not constructing classes with explicit destructors (non-T classes) on the stack.
laalto