1 /* PR middle-end/99502 - missing -Warray-bounds on partial out of bounds
4 { dg-options "-O2 -Wall" } */
6 inline void* operator new (__SIZE_TYPE__, void *p) { return p; }
8 struct B0 { int b0i, b0a[0]; };
9 struct B1: virtual B0 { int b1i, b1a[0]; };
10 struct B2: virtual B0 { int b2i, b2a[0]; };
11 struct D1: B1, B2 { int d1i, d1a[0]; };
12 struct D2: D1 { int d2i, d2a[0]; };
13 struct D3: D2 { int d3i, d3a[0]; };
21 char *p = new char[sizeof (D1)];
27 char *p = new char[sizeof (D1) - 1];
28 new (p) D1 (); // { dg-warning "-Warray-bounds" }
36 D1 *p = (D1*)new char[sizeof (D1)];
37 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" "pr99630" { xfail *-*-* } }
42 D1 *p = (D1*)new char[3];
43 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" }
51 D1 *p = (D1*)new char[sizeof (D1)];
52 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
57 D1 *p = (D1*)new char[3];
58 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
66 D1 *p = (D1*)new char[sizeof (D1)];
67 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
72 D1 *p = (D1*)new char[3];
73 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
81 D1 *p = (D1*)new char[sizeof (D1)];
82 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
87 D1 *p = (D1*)new char[3];
88 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
97 char *p = new char[sizeof (D2)];
103 char *p = new char[sizeof (D2) - 1];
104 new (p) D2 (); // { dg-warning "-Warray-bounds" }
112 D2 *p = (D2*)new char[sizeof (D2)];
113 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" "pr99630" { xfail *-*-* } }
118 D2 *p = (D2*)new char[3];
119 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" }
127 D2 *p = (D2*)new char[sizeof (D2)];
128 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
133 D2 *p = (D2*)new char[3];
134 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
142 D2 *p = (D2*)new char[sizeof (D2)];
143 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
148 D2 *p = (D2*)new char[3];
149 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
157 D2 *p = (D2*)new char[sizeof (D2)];
158 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
163 D2 *p = (D2*)new char[3];
164 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
172 D2 *p = (D2*)new char[sizeof (D2)];
173 *p->d2a = __LINE__; // { dg-warning "-Warray-bounds" }
178 D2 *p = (D2*)new char[3];
179 *p->d2a = __LINE__; // { dg-warning "-Warray-bounds" }
188 char *p = new char[sizeof (D3)];
194 char *p = new char[sizeof (D3) - 1];
195 new (p) D3 (); // { dg-warning "-Warray-bounds" }
203 D3 *p = (D3*)new char[sizeof (D3)];
204 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" "pr99630" { xfail *-*-* } }
209 D3 *p = (D3*)new char[3];
210 *p->b0a = __LINE__; // { dg-warning "-Warray-bounds" }
218 D3 *p = (D3*)new char[sizeof (D3)];
219 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
224 D3 *p = (D3*)new char[3];
225 *p->b1a = __LINE__; // { dg-warning "-Warray-bounds" }
233 D3 *p = (D3*)new char[sizeof (D3)];
234 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
239 D3 *p = (D3*)new char[3];
240 *p->b2a = __LINE__; // { dg-warning "-Warray-bounds" }
248 D3 *p = (D3*)new char[sizeof (D3)];
249 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
254 D3 *p = (D3*)new char[3];
255 *p->d1a = __LINE__; // { dg-warning "-Warray-bounds" }
263 D3 *p = (D3*)new char[sizeof (D3)];
264 *p->d2a = __LINE__; // { dg-warning "-Warray-bounds" }
269 D3 *p = (D3*)new char[3];
270 *p->d2a = __LINE__; // { dg-warning "-Warray-bounds" }
278 D3 *p = (D3*)new char[sizeof (D3)];
279 *p->d3a = __LINE__; // { dg-warning "-Warray-bounds" }
284 D3 *p = (D3*)new char[3];
285 *p->d3a = __LINE__; // { dg-warning "-Warray-bounds" }