https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84395
Bug ID: 84395 Summary: -Wstringop-truncation where -Wstringop-overflow is expected Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The test case below triggers what looks like a bogus -Wstringop-truncation warning when it instead should trigger -Wstringop-overflow. The -Wstringop-truncation warning indicates that the checker considers the size of the entire array (i.e., 3 * 7 chars) when it should consider the size of the subarray a[i] (i.e., 7 chars). The missing -Wstringop-overflow suggests this checker is doing the same. $ cat t.c && gcc -O2 -S -Wall -Wextra t.c char a[3][7]; void f (const char *s, int i) { __builtin_strncpy (a[i], s, 21); // -Wstringop-truncation but no -Wstringop-overflow? a[i][6] = 0; } t.c: In function ‘f’: t.c:5:3: warning: ‘__builtin_strncpy’ specified bound 21 equals destination size [-Wstringop-truncation] __builtin_strncpy (a[i], s, 21); // -Wstringop-truncation but no -Wstringop-overflow? ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~