https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116563
Bug ID: 116563 Summary: Wtautological-compare for memcmp and friends Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rv at rasmusvillemoes dot dk Target Milestone: --- I was a bit surprised to learn that a semi-obvious bug like memcmp(counter2, counter2, 16) is not flagged by -Wtautological-compare. The optimizer certainly knows that the call can be replaced by a constant 0. Would it be possible to include cases like strcmp(x, x), strncmp(x, x, *), memcmp(x, x, *) etc. in -Wtautological-compare ? Or, given that Wtautological-compare is in -Wall, maybe introduce another warning for such cases (or teach -Wtautological-compare an optional level). For most of these bugs I think it's fine to only warn when the two arguments are exactly the same at the source level. So strcmp(s, s+0) doesn't need to warn, and could provide an easy work-around for a false-positive warning.