3 ms·
That code does not violate the aliasing rules in any case. The two functions you wrote are not the same; the first re-reads *x which may return a different val
by kbolino 2y ago
That code does not violate the aliasing rules in any case.
The two functions you wrote are not the same; the first re-reads *x which may return a different value than 2 if *x was modified in between the first and third lines of the function by another thread (or hardware). However, since x is not marked volatile, the compiler will usually optimize the first function to behave the same as the second.