https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92014
Bug ID: 92014 Summary: [10 Regression] bogus warning: writing 8 bytes into a region of size 1 in timezone/zic.c Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Last week's r276603 has introduced a bug into the count_nonzero_bytes function that leads to a false positive -Wstringop-overflow in glibc's timezone/zic.c. The test case below reproduces the bogus warning. $ cat zic.i && gcc -S -O2 -Wall zic.i struct { char *s1, *s2; char c; } z; void f (char **a, int i, int j) { char * cp = __builtin_strchr (a[i], '%'); if (cp && *++cp != 's') return; z.s1 = __builtin_strdup (a[i]); if (!z.s1) __builtin_abort (); z.s2 = __builtin_strdup (a[j]); if (!z.s2) __builtin_abort (); z.c = cp ? *cp : '\0'; } zic.i: In function âfâ: zic.i:21:7: warning: writing 8 bytes into a region of size 1 [-Wstringop-overflow=] 21 | z.c = cp ? *cp : '\0'; | ~~~~^~~~~~~~~~~~~~~~~ zic.i:4:8: note: destination object declared here 4 | char c; | ^