The compiler will, within the limits of its rights, fully optimize this function, since it has no observable side effects (from the point of view of standard C).
As for why your compilers don't do this, I can't explain it! (Although, of course, they are not required to do this.)
source
share