https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101361
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Target Milestone|--- |12.0 Resolution|--- |FIXED --- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> --- Comment 1 was fixed by my changes above. Comment 0 compiles without warnings since gcc 12.1.0, I'm not sure what fixed it yet. Comment 12 (and comment 13) is a different issue, not originating inside std::string. The problem there is simply that the compiler doesn't know that beg <= end is an invariant of your struct V, so it cannot prove that the len passed to memcmp is not negative. The fix is simple: if (len > 0) {