I've been reading quite a few question on SO regarding code execution guarantees in optimised code, so I'm trying to compile a list of reasons as to what allows/stops the compiler from reordering code sequence.
I've start the answer with what is generally true but I've not added quotes from the standard (this was taken from my experience). I would ask that you add to the answer provided if there is anything that was forgotten or expand/correct on points that are there.
Also, can someone verify for me if code blocks are not subject to reordering. I.e.
void fn()
{
{ /* code block 1 */ ... }
{ /* code block 2 */ ... }
}
Is it possible for code in code block 1
to mingle or be executed prior to code block 2
?