This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/84228] New: Bogus -Wstringop-truncation with -g
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Feb 2018 09:50:06 +0000
- Subject: [Bug tree-optimization/84228] New: Bogus -Wstringop-truncation with -g
- Auto-submitted: auto-generated
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.