Regarding OOO, lets assume I have one process only (with one thread) that runs this code:
void foo() {
if (x == 0) {
return;
}
y->data = 5;
}
Now, lets assume I know that y
is valid only if x
is not zero.
from hardware perspective, can the CPU execute y->data = 5
before reading x
?
It may cause the CPU to access a NULL/garbage pointer and crashs.
And if not, what is the reason for this? because if/while/for/goto are control statements and the CPU will not fetch ahead instructions when it sees a control statement?
A I remember, OOO should be 100% transparent to one thread executing its instructions.