https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79950
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #5) > (In reply to David Binderman from comment #4) > > Anyway, I think some progress could be made by finding the pattern > > > > for (something = 0; something <= somethingElse.size(); ++ something) > > > > at compile time, which is what the static analyser 'cppcheck' seems to be > > doing. > > That's what I said, it would have to be a special case built in to the > front-end. And it has to be a lot smarter than that, as there's nothing wrong with: for (unsigned i = 0; i <= v.size(); ++i) std::cout << i; It's only a problem if you do v[i] when i == v.size()