https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110129
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Ever confirmed|0 |1 Last reconfirmed| |2023-06-05 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So in C++, it is required that forward process happens so GCC (due to the -ffinite-loops option which is only enabled for -O2 and above) will remove infinite loops for C++. Now your goldbolt link is using the C++ front-end while your comment says using C front-end. Once I change goldbolt to using C sources, the infinite loop is NOT removed as expected (as -ffinite-loops is only enabled for C++).