https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85359
Bug ID: 85359 Summary: duplicate -Wstringop-overflow for a strcmp call with a nonstring pointer Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC issues two warnings for a single call to strcmp in the following test case. One warning is issued from expand_builtin_strcmp() in builtins.c and the other from expand_call() in calls.c called directly from the former. $ cat z.c && gcc -O2 -S -Wall z.c int f (__attribute__ ((nonstring)) const char *d, const char *s) { return __builtin_strcmp (d, s); } z.c: In function ‘f’: z.c:3:10: warning: ‘__builtin_strcmp’ argument 1 declared attribute ‘nonstring’ [-Wstringop-overflow=] return __builtin_strcmp (d, s); ^~~~~~~~~~~~~~~~~~~~~~~ z.c:1:48: note: argument ‘d’ declared here int f (__attribute__ ((nonstring)) const char *d, const char *s) ~~~~~~~~~~~~^ z.c:3:10: warning: ‘__builtin_strcmp’ argument 1 declared attribute ‘nonstring’ [-Wstringop-overflow=] return __builtin_strcmp (d, s); ^~~~~~~~~~~~~~~~~~~~~~~ z.c:1:48: note: argument ‘d’ declared here int f (__attribute__ ((nonstring)) const char *d, const char *s) ~~~~~~~~~~~~^