-
Notifications
You must be signed in to change notification settings - Fork 26
Description
The section “Eventually, nothing” states:
according to the C standard, compilers are allowed to assume that the program contains no infinite loops without side-effects.
This is inaccurate; the precise statement from the C standard (C11, 6.8.5) states:
An iteration statement whose controlling expression is not a constant expression, that performs no input/output operations, does not access volatile objects, and performs no synchronization or atomic operations in its body, controlling expression, or (in the case of a for statement) its expression-3, may be assumed by the implementation to terminate.
Loops with constant controlling expressions, as well as loops that access volatile variables cannot be optimized out in C; the fact that they were was a simple bug in LLVM. It is probably more accurate to say that the C standard permits certain infinite loops to be optimized out.