1 /* PR middle-end/82456 - missing -Wstringop-overflow on strcpy reading past
2 the end of an array
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
5
6 void fcst (char *d)
7 {
8 char a[2] = "0";
9
10 __builtin_strcpy (d, a + 3); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" }
11 }
12
13 void frng (char *d, int i)
14 {
15 char a[2] = "0";
16
17 if (i < 3)
18 i = 3;
19
20 __builtin_strcpy (d, a + i); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" }
21 }
22
23 void gcst (char *d)
24 {
25 char a[2] = "0";
26
27 __builtin_strcpy (d, a + 2); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" }
28 }
29
30 void grng (char *d, int i)
31 {
32 char a[2] = "0";
33
34 if (i < 2)
35 i = 2;
36
37 __builtin_strcpy (d, a + i); // { dg-warning "\\\[-W(array-bounds|stringop-overread)" }
38 }
39
40 /* { dg-prune-output "-Wuninitialized" } */