111
|
1 /* PR middle-end/79223 - missing -Wstringop-overflow on a memmove overflow
|
|
2 { dg-do compile }
|
131
|
3 { dg-additional-options "-O2 -Wall -Wno-array-bounds -std=gnu99" } */
|
111
|
4
|
|
5 typedef __SIZE_TYPE__ size_t;
|
|
6
|
|
7 extern void* memcpy (void*, const void*, size_t);
|
|
8 extern void* mempcpy (void*, const void*, size_t);
|
|
9 extern void* memmove (void*, const void*, size_t);
|
|
10
|
|
11 char d[3];
|
|
12 char s[4];
|
|
13
|
|
14 size_t range (void)
|
|
15 {
|
|
16 extern size_t size ();
|
|
17 size_t n = size ();
|
|
18 if (n <= sizeof d)
|
|
19 return sizeof d + 1;
|
|
20
|
|
21 return n;
|
|
22 }
|
|
23
|
|
24 void test_memcpy (void)
|
|
25 {
|
|
26 memcpy (d, s, range ()); /* { dg-warning ".memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
|
|
27 }
|
|
28
|
|
29 void test_mempcpy (void)
|
|
30 {
|
|
31 mempcpy (d, s, range ()); /* { dg-warning ".mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
|
|
32 }
|
|
33
|
|
34 void test_memmove (void)
|
|
35 {
|
|
36 memmove (d + 1, d, range ()); /* { dg-warning ".memmove. writing 4 or more bytes into a region of size 2 overflows the destination" } */
|
|
37 }
|