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.
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
)
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);
26 # ivtmp.7_22 = PHI <ivtmp.7_4(3), ivtmp.7_5(4)>
28 _1 = (void *) ivtmp.7_22;
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);