https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79095
--- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> --- I agree that calling v.resize(v.size() - 0) when v.size() is zero is a bug in the program and diagnosing it should be a good thing (I think that corresponds to the test case I pasted in comment #2 and what I based my patch with the trap on.) If your patch avoids the warning when the if guard in the test case in comment #0 is uncommented that would seem like a fix. As a separate change (in GCC 8) I do think it would be worth considering the idea of inserting the trap, and also having tree-loop-distribution.c issue a better warning when it detects an out of bounds loop like this one.