https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116950
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- > p.s. even though -ffinite-loops seems to be default at -O2 It is enabled for C++ yes but NOT C by default. That might be the difference you saw when reducing the code.