As John Regehr says in the article Compilers and Termination Revisited in the C 1999 standard it is unclear whether the as-if rule rule allows compilers to eliminate infinite loops or not. The fact that reasonable people can come to different conclusions says it is underspecified.
In the C 2011 standard this was clarified and it now forbids optimizing away an infinite loop if the control statement is a constant expression, for example:
while (1) { }
is not fair game for optimization. You can find more detail in my Stackoverflow answer here
Log In
or
Sign in with Github
Sign in with Twitter
or
Sign in with Github
Sign in with Twitter
Sign Up
or
Sign in with Github
Sign in with Twitter
Reset Password
Enter the email address associated with your account, and we'll email you a link to reset your password.
In the C 2011 standard this was clarified and it now forbids optimizing away an infinite loop if the control statement is a constant expression, for example: is not fair game for optimization. You can find more detail in my Stackoverflow answer here