1 /* PR middle-end/92936 - missing warning on a past-the-end store to a PHI
2    { dg-do compile }
3    { dg-options "-O2 -Wall -Wno-array-bounds" } */
4 
5 typedef __SIZE_TYPE__ size_t;
6 
7 void* malloc (size_t);
8 void* memset (void*, int, size_t);
9 
10 extern char a3[3], a5[5], a9[9];
11 
12 extern int cnd[];
13 
f2(void)14 void* f2 (void)
15 {
16   char *p0 = cnd[0] ? a3 : 0;
17   char *p1 = cnd[1] ? a5 : p0;
18 
19   return memset (p1, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
20 }
21 
f3(void)22 void* f3 (void)
23 {
24   char *p0 = cnd[0] ? a3 : 0;
25   char *p1 = cnd[1] ? a5 : 0;
26   char *p2 = cnd[2] ? p0 : p1;
27 
28   return memset (p2, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
29 }
30 
f3_2(void)31 void* f3_2 (void)
32 {
33   char *p0 = cnd[0] ? a3 : 0;
34   char *p1 = cnd[1] ? a5 : 0;
35   char *p2 = cnd[2] ? p1 : p0;
36 
37   return memset (p2, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
38 }
39 
f3_3(void)40 void* f3_3 (void)
41 {
42   char *p0 = cnd[0] ? a5 : 0;
43   char *p1 = cnd[1] ? p0 : a5;
44   char *p2 = cnd[2] ? p1 : p0;
45 
46   return memset (p2, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
47 }
48 
f4(void)49 void* f4 (void)
50 {
51   char *p0 = cnd[0] ? a3 : 0;
52   char *p1 = cnd[1] ? a5 : 0;
53   char *p2 = cnd[2] ? p0 : 0;
54   char *p3 = cnd[3] ? p1 : p2;
55 
56   return memset (p3, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
57 }
58 
f9(void)59 void* f9 (void)
60 {
61   char *p0 = cnd[0] ? a5 : 0;
62   char *p1 = cnd[1] ? a5 + 1 : 0;
63   char *p2 = cnd[2] ? a5 + 2 : 0;
64   char *p3 = cnd[3] ? a5 + 3 : 0;
65   char *p4 = cnd[4] ? a5 + 4 : 0;
66 
67   char *p5 = cnd[5] ? p0 : p1;
68   char *p6 = cnd[6] ? p5 : p2;
69   char *p7 = cnd[7] ? p6 : p3;
70   char *p8 = cnd[8] ? p7 : p4;
71   char *p9 = cnd[9] ? p8 : p5;
72 
73   return memset (p9, 0, 6);   // { dg-warning "writing 6 bytes into a region of size 5" }
74 }
75