https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87420
Bug ID: 87420 Summary: missing warning for strcpy of an unterminated array with variable offset Product: gcc Version: 9.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: --- When the source array involves a variable index/offset, GCC 9 issues a warning for a strcpy call with a single-dimensional unterminated array but fails to issue the same warning when the array has multiple dimensions, as shown in the test case below: $ cat c.c && gcc -O2 -S -Wall -Wextra -Wpedantic c.c const char a[] = { '1', '2', '3' }; const char b[][3] = { { '1', '2' }, { '1', '2', '3' } }; void f (char *d, int i) { __builtin_strcpy (d, &a[i]); // warning (good) } void g (char *d, int i) { __builtin_strcpy (d, &b[1][i]); // missing warning } c.c: In function ‘f’: c.c:6:3: warning: ‘strcpy’ argument missing terminating nul [-Wstringop-overflow=] 6 | __builtin_strcpy (d, &a[i]); // warning (good) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ c.c:1:12: note: referenced argument declared here 1 | const char a[] = { '1', '2', '3' }; | ^