blob: dbad9566bd3e42587c18ac763c397392aa59bee6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/* PR tree-optimization/86196 - Bogus -Wrestrict on memcpy between array
elements at unequal indices
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
typedef __SIZE_TYPE__ size_t;
extern void* memcpy (void*, const void*, size_t);
struct S
{
int n;
void * p;
};
/* Test case submitted in the PR. */
void pr86196_c0 (struct S * a, size_t n)
{
for (size_t i = 0, j = 0; i != n; ++i)
{
if (a[i].n == 0)
{
if (i != j)
memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */
++j;
}
}
}
/* Reduced test case. */
void pr86196_c1 (struct S *a, int i, int j)
{
if (i != j)
memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */
}
|