This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/83404] New: bogus stringop-overflow warning
- From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 12 Dec 2017 22:29:40 +0000
- Subject: [Bug middle-end/83404] New: bogus stringop-overflow warning
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83404
Bug ID: 83404
Summary: bogus stringop-overflow warning
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: bernd.edlinger at hotmail dot de
Target Milestone: ---
$ cat test.c
#include <string.h>
main()
{
char x[12];
strncpy(x, "", 12);
strncat(x, "aa", 1);
strncat(x, "aa", 2);
strncat(x, "aa", 3);
}
$ gcc -Wall -W test.c
test.c: In function ‘main’:
test.c:7:3: warning: ‘strncat’ specified bound 2 equals source length
[-Wstringop-overflow=]
strncat(x, "aa", 2);
^~~~~~~~~~~~~~~~~~~
The warning here is a bit surprising to me.