Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / Wrestrict-2.c
blobd73e144170ad834ea92e4aaf4653d6c9f243dd87
1 /* Test to verify that the temporary doesn't trigger a bogus -Warray-bounds
2 warning. Distilled from libat_exchange_large_inplace in libatomic/gexch.c.
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 typedef typeof (sizeof 0) size_t;
8 extern void *memcpy (void*, const void*, size_t);
10 void libat_exchange_large_inplace (size_t n, void *mptr, void *vptr)
12 char temp[1024];
14 size_t i = 0;
16 for (i = 0; n >= 1024; i += 1024, n -= 1024)
18 memcpy (temp, mptr + i, 1024);
20 /* The memcpy call below results in the following:
21 unsigned long ivtmp.7;
23 ivtmp.7_4 = (unsigned long) mptr_9(D);
24 ...
25 <bb 4>
26 # ivtmp.7_22 = PHI <ivtmp.7_4(3), ivtmp.7_5(4)>
27 ...
28 _1 = (void *) ivtmp.7_22;
29 ...
30 memcpy (_1, _2, 1024);
32 Treating _1 as a pointer results in the bogus:
33 warning: 'memcpy' offset 0 is out of the bounds [0, 8] of object 'ivtmp.7' with type 'long unsigned int' [-Warray-bounds]
34 memcpy (mptr + i, vptr + i, 1024);
35 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 memcpy (mptr + i, vptr + i, 1024);
39 memcpy (vptr + i, temp, 1024);