ITADN

Eventually, nothing: factually inaccuracy about the C standard

#20Opennneonneo 创建于 2023-06-06
N
nneonneocommented
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.
1 条评论