Can compiler reorder variable setting and throw()
op in C++? Or, does standard C++ 14882-1998 allows or prohibit compiler of this transform?
For code:
bool funct()
{
bool succeeded = false;
bool res_throw = false;
try {
throw("it");
succeeded = true;
}
catch(...) {
res_throw = true;
}
cout << "Result of throw: " << res_throw << endl;
cout << "succeeded: " << succeeded << endl;
return succeeded;
}
Can the output be a
Result of throw: true
succeeded: true
The Standard says: "[intro.execution]#7":
modifying an object .. are all side effects, which are changes in the state of the execution environment
At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place
Is throw
statement a sequence point?