[Bug tree-optimization/83007] New: [8 Regression] -Wstringop-overflow false positive
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 15 14:59:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83007
Bug ID: 83007
Summary: [8 Regression] -Wstringop-overflow false positive
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: msebor at gcc dot gnu.org
Target Milestone: ---
Isolated from ./libgomp/target.c:
$ cat target.c
#include <string.h>
#include <stdlib.h>
char *prefix;
char *suffix;
void a ()
{
char *next = 0;
char *cur;
char *plugin_name;
cur = "nvptx";
plugin_name = (char *) malloc (1 + (next ? next - cur : strlen (cur))
+ strlen (prefix) + strlen (suffix));
strcpy (plugin_name, prefix);
strncat (plugin_name, cur, next ? next - cur : strlen (cur));
strcat (plugin_name, suffix);
}
$ ./xgcc -B. target.c -O2 -Wall
target.c: In function ‘a’:
target.c:15:3: warning: ‘strncat’ specified bound 5 equals source length
[-Wstringop-overflow=]
strncat (plugin_name, cur, next ? next - cur : strlen (cur));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think it's false positive as plugin_name is long enough.
Can you Martin please take a look?
More information about the Gcc-bugs
mailing list