Skip to content

Eventually, nothing: factually inaccuracy about the C standard #20

@nneonneo

Description

@nneonneo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions