I am using C++98. To what extent can function calls be reordered? I am not using any global state, only state of objects local to the function.
My particular case is:
{
RaiiType T;
Object1.FunctionCall();
Object2.FunctionCall();
}
Where Object1 and Object2 are declared in the next scope up. Is the constructor for T
permitted to be reordered after either function call, assuming that it can be trivially proven (at least to a human) that there are no dependencies between the construction and the function calls?
In my particular case, the RAII object is used to time the execution of the function calls.
So long as a standards-compliant program could not tell the difference in its observable behavior, the compiler (as well as other components in the system) may freely reorder instructions and operations however it likes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With