[Bug tree-optimization/85754] New: missing -Wrestrict on memcpy with non-constant offsets less than size
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 11 21:14:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85754
Bug ID: 85754
Summary: missing -Wrestrict on memcpy with non-constant offsets
less than size
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
When memcpy is used to copy sequences at offsets within the same array
-Wrestrict uses the full range of each of the offsets even when the offsets are
trivially related and. When the distance between the offsets is less than the
size of the copy the copy is guaranteed to overlap, yet -Wrestrict is not
issued. The checker could work harder and try to detect at least some of these
cases.
$ cat z.c && gcc -O2 -S -Wall -fdump-tree-vrp=/dev/stdout z.c
void f (char *p, int i)
{
__builtin_memcpy (p + i, p + i + 4, 32); // missing -Wrestrict
}
...
Value ranges after VRP:
_1: ~[2147483648, 18446744071562067967]
_2: ~[2147483652, 18446744071562067971]
...
f (char * p, int i)
{
sizetype _1;
sizetype _2;
char * _3;
char * _4;
<bb 2> [local count: 1073741825]:
_1 = (sizetype) i_5(D);
_2 = _1 + 4;
_3 = p_6(D) + _2;
_4 = p_6(D) + _1;
__builtin_memcpy (_4, _3, 32);
return;
}
More information about the Gcc-bugs
mailing list