https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85365
Bug ID: 85365 Summary: -Wrestrict false positives with -fsanitize=undefined Product: gcc Version: 8.0.1 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- This small testcase warns 3 time when compiled with 8.0.1@r259308: extern char a[], b[], d[]; int c, e; char *strcpy(char *, const char *); char *strcat(char *, const char *); __SIZE_TYPE__ strlen(char *); void t1(char *g) { strcpy(g + 4, c ? b : a); e = strlen(g + 4); } void t2(char *g) { strcpy(g + 4, c ? b : a); strcat(g + 4, d); } void t3(char *g) { strcat(g + 4, c ? b : a); strcat(g + 4, d); } # gcc-8 -c -O2 -fsanitize=undefined -Wrestrict t.c t.c: In function 't1': t.c:8:3: warning: 'strcpy' source argument is the same as destination [-Wrestrict] strcpy(g + 4, c ? b : a); ^~~~~~~~~~~~~~~~~~~~~~~~ t.c: In function 't2': t.c:13:3: warning: 'strcpy' source argument is the same as destination [-Wrestrict] strcpy(g + 4, c ? b : a); ^~~~~~~~~~~~~~~~~~~~~~~~ t.c: In function 't3': t.c:18:3: warning: 'strcat' source argument is the same as destination [-Wrestrict] strcat(g + 4, c ? b : a); ^~~~~~~~~~~~~~~~~~~~~~~~ gcc-7 didn't warn for this testcase.