https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84228
Bug ID: 84228 Summary: Bogus -Wstringop-truncation with -g Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- char *strncpy (char *, const char *, __SIZE_TYPE__); struct S { char arr[64]; }; int foo (struct S *p1, const char *a) { if (a) goto err; strncpy (p1->arr, a, sizeof p1->arr); p1->arr[3] = '\0'; err: return 0; } $ ./cc1 -quiet t.c -Wstringop-truncation -O2 -g t.c: In function ‘foo’: t.c:12:3: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation] strncpy (p1->arr, a, sizeof p1->arr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ the warning is gone without -g.