Goto out of a block: do destructors get called?

The C++ Standard says:

On exit from a scope (however
accomplished), destructors (12.4) are
called for all constructed objects
with automatic storage duration
(3.7.2) (named objects or temporaries)
that are declared in that scope, in
the reverse order of their
declaration.

So the answer is “yes”.

Leave a Comment

tech