https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119999
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Right, it's undefined to keep looping like that, so the compiler assumes that the loop must terminate, which can only happen if the assert fails, so it optimizes it to fail.