On exit from a scope (however accomplished), objects with automatic storage
duration ([basic.stc.auto]) that have been constructed in that scope are destroyed
in the reverse order of their construction.
Transfer out of a loop, out of a block, or back
past
an initialized variable with automatic storage duration involves the
destruction of objects with automatic storage duration that are in
scope at the point transferred from but not at the point transferred to.
However, the program can be terminated (by calling
std::exit() or
std::abort() ([support.start.term]), for example) without
destroying class objects with automatic storage duration.
The break statement shall occur only in an
iteration-statement or a switch statement and causes
termination of the smallest enclosing iteration-statement or
switch statement; control passes to the statement following the
terminated statement, if any.
The
continue
statement shall occur only in an
iteration-statement
and causes control to pass to the loop-continuation portion of the
smallest enclosing iteration-statement, that is, to the end
of the loop.
More precisely, in each of the statements
while (foo) {
{
// ...
}
contin: ;
}
do {
{
// ...
}
contin: ;
} while (foo);
for (;;) {
{
// ...
}
contin: ;
}
a continue not contained in an enclosed iteration statement is
equivalent to gotocontin.
A return statement with
no operand shall be used only in a function whose return type is
cvvoid, a constructor ([class.ctor]), or a
destructor ([class.dtor]).
A return statement with an operand of type void shall be used only
in a function whose return type is cvvoid.
A return statement with any other operand shall be used only
in a function whose return type is not cvvoid;
the return statement initializes the
glvalue result or prvalue result object of the (explicit or implicit) function call
by copy-initialization ([dcl.init]) from the operand.
A return statement can involve
an invocation of a constructor to perform a copy or move of the operand
if it is not a prvalue or if its type differs from the return type of the function.
A copy operation associated with a return statement may be elided or
converted to a move operation if an automatic storage duration variable is returned ([class.copy]).
The copy-initialization of the result of the call is sequenced before the
destruction of temporaries at the end of the full-expression established
by the operand of the return statement, which, in turn, is sequenced
before the destruction of local variables ([stmt.jump]) of the block
enclosing the return statement.