https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98663
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- We have a warning but only if the loop doesn't have multiple exits. In your case it has multiple exits and warning on it would be only a false positive for perfectly valid code that would just assume that read[x] would be 0xFFFF for at least one i in between 0 and 449 inclusive. Compiler really doesn't have an intention to punish users and break their code, but just assumes the code doesn't trigger undefined behavior. In particular in this case, in some places it computes that the maximum number of iterations of the loop is bounded by not invoking UB with read[450], some other pass will compute value ranges of the iteration and yet another piece of code will determine that the i < 450 condition is always true due to the limited range and thus can be optimized away.