shafik

Shafik Yaghmour

RATING

0.01
Karma: 0.00
avatar
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