The C11 standard appears to imply that iteration statements with constant controlling expressions should not be optimized out. I\'m taking my advice from this answer, which
I'm sorry if this is absurdly not the case, I stumbled upon this post and I know because my years using Gentoo Linux distro that if you want the compiler to not optimize your code you should use -O0(Zero). I was curious about it, and compiled and ran the above code, and the loop do goes indefinitely. Compiled using clang-9:
cc -O0 -std=c11 test.c -o test