https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104635
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Szüllő Ádám from comment #4) > i understand that missing return value is undefined behaviour. > my point is, that this should be limited to the act of return (return with > garbage, segfault, stuck in an infinite loop _after_ the for loop) No. > what i can't understand is, that even if GCC sees that the loop exit cannot > be possibly reached, how that will lead to the for loop disobeying the test > expression. Undefined behaviour does not mean "returns garbage, but otherwise behaves as you expect". There is no bound on how surprising undefined behaviour can be.