https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98975
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The only thing that should be fixed is whatever code invokes the UB. There is no bug on the compiler side, you essentially end up with __builtin_unreachable (); in place of the loop. You can use -fsanitize=unreachable to get a runtime diagnostics instead if the UB is turned into __builtin_unreachable ().