https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83404
Bug ID: 83404 Summary: bogus stringop-overflow warning Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de Target Milestone: --- $ cat test.c #include <string.h> main() { char x[12]; strncpy(x, "", 12); strncat(x, "aa", 1); strncat(x, "aa", 2); strncat(x, "aa", 3); } $ gcc -Wall -W test.c test.c: In function ‘main’: test.c:7:3: warning: ‘strncat’ specified bound 2 equals source length [-Wstringop-overflow=] strncat(x, "aa", 2); ^~~~~~~~~~~~~~~~~~~ The warning here is a bit surprising to me.