Under which circumstances are the following two codes not equivalent?
{
// some code, may throw and/or have side effects
}
try {
// same code as above
} catch(...) {
throw;
}
edit Just to clarify, I'm not interested in (i) deviations from above pattern (such as more code in the catch block) nor (ii) intended to invite patronising comments about the proper usage of try
-catch
blocks.
I'm looking for a qualified answer referring to the C++ standard. This question was prompted by a comment by Cheers and hth. - Alf to this answer of mine, stating w/o further explanation that above codes are not equivalent.
edit they are indeed different. stack un-winding will be done in the latter, but not necessarily in the former, depending on whether an exception handler (some catch
block higher up the stack) is found at run time.