[Bug middle-end/93519] New: bogus -Wrestrict for strcpy(d, s) call guarded by d != s
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 31 00:45:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93519
Bug ID: 93519
Summary: bogus -Wrestrict for strcpy(d, s) call guarded by d !=
s
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
This was reported in RHBZ #1796688 (and previously for memcpy in bug 83456).
The warning is obviously incorrect here:
#include <string.h>
static char *
str_numth(char *dest, char *num, int type)
{
if (dest != num)
strcpy(dest, num);
strcat(dest, "foo");
return dest;
}
void
DCH_to_char(char *in, char *out, int collid)
{
char *s = out;
str_numth(s, s, 42);
}
$ gcc -Wall -c -O2 wtest.c
wtest.c: In function 'DCH_to_char':
wtest.c:7:3: warning: 'strcpy' source argument is the same as destination
[-Wrestrict]
7 | strcpy(dest, num);
| ^~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list