The compiler (in C) is allowed to assume that infinite loops eventually terminate. This can lead to these kinds of loops not actually running forever when built with an optimizing compiler.
ISO/IEC 9899:2017 §6.8.5 “Iteration statements”, paragraph 6:
“An iteration statement may be assumed by the implementation to terminate if its controlling expression is not a constant expression, and none of the following operations are performed in its body, controlling expression or (in the case of a for statement) its expression-3: – input/output operations – accessing a volatile object – synchronization or atomic operations."
It can, for example, simply optimize it away, assuming non-productive infinite loops are stupid and not reflective of what the code will actually do.