2 /* { dg-options "-O2" } */
4 typedef __SIZE_TYPE__
size_t;
5 extern void *malloc (size_t);
6 extern void free (void *);
7 extern void abort (void);
57 #define T(X, S0, S1) \
58 if (__builtin_object_size (X, 0) != (S0)) \
60 if (__builtin_object_size (X, 1) != (S1)) \
62 if (__builtin_object_size (X, 2) != (S0)) \
64 if (__builtin_object_size (X, 3) != (S1)) \
66 #define TS(X, S0) T(&X, S0, sizeof (X))
67 #define TA(X, S0, S1) \
68 T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
69 #define TF(X, S0) TA(X, S0, S0)
78 union A
*a1
= malloc (s
);
79 union A
*a2
= malloc (o
+ 212);
88 a2
= malloc (o
+ 212);
97 union B
*b1
= malloc (s
);
98 union B
*b2
= malloc (o
+ 212);
104 s
= sizeof (union B
);
107 b2
= malloc (o
+ 212);
113 s
= sizeof (union B
);
116 b2
= malloc (o
+ 212);
123 s
= sizeof (struct C
);
124 o
= __builtin_offsetof (struct C
, c2
);
125 struct C
*c1
= malloc (s
);
126 struct C
*c2
= malloc (o
+ 212);
132 s
= sizeof (struct C
);
133 o
= __builtin_offsetof (struct C
, c2
);
135 c2
= malloc (o
+ 212);
136 TS (c1
->c2
.a1
, s
- o
);
138 TS (c2
->c2
.a1
, s
- o
);
141 s
= sizeof (struct C
);
142 o
= __builtin_offsetof (struct C
, c2
);
144 c2
= malloc (o
+ 212);
145 TF (c1
->c2
.a2
, s
- o
);
147 TF (c2
->c2
.a2
, s
- o
);
151 s
= sizeof (struct D
);
152 o
= __builtin_offsetof (struct D
, d2
);
153 struct D
*d1
= malloc (s
);
154 struct D
*d2
= malloc (o
+ 212);
160 s
= sizeof (struct D
);
161 o
= __builtin_offsetof (struct D
, d2
);
163 d2
= malloc (o
+ 212);
164 TS (d1
->d2
.b1
, s
- o
);
166 TS (d2
->d2
.b1
, s
- o
);
169 s
= sizeof (struct D
);
170 o
= __builtin_offsetof (struct D
, d2
);
172 d2
= malloc (o
+ 212);
173 TS (d1
->d2
.b2
.a1
, s
- o
);
175 TS (d2
->d2
.b2
.a1
, s
- o
);
178 s
= sizeof (struct D
);
179 o
= __builtin_offsetof (struct D
, d2
);
181 d2
= malloc (o
+ 212);
182 TF (d1
->d2
.b2
.a2
, s
- o
);
184 TF (d2
->d2
.b2
.a2
, s
- o
);
188 s
= sizeof (union E
);
189 o
= __builtin_offsetof (union E
, e1
.c2
);
190 union E
*e1
= malloc (s
);
191 union E
*e2
= malloc (o
+ 212);
197 s
= sizeof (union E
);
198 o
= __builtin_offsetof (union E
, e1
.c2
);
200 e2
= malloc (o
+ 212);
201 TS (e1
->e1
.c2
.a1
, s
- o
);
203 TS (e2
->e1
.c2
.a1
, s
- o
);
206 s
= sizeof (union E
);
207 o
= __builtin_offsetof (union E
, e1
.c2
);
209 e2
= malloc (o
+ 212);
210 TF (e1
->e1
.c2
.a2
, s
- o
);
212 TF (e2
->e1
.c2
.a2
, s
- o
);
215 s
= sizeof (union E
);
216 o
= __builtin_offsetof (union E
, e1
.c2
);
218 e2
= malloc (o
+ 212);
225 s
= sizeof (union F
);
226 o
= __builtin_offsetof (union F
, f2
.d2
);
227 union F
*f1
= malloc (s
);
228 union F
*f2
= malloc (o
+ 212);
234 s
= sizeof (union F
);
235 o
= __builtin_offsetof (union F
, f2
.d2
);
237 f2
= malloc (o
+ 212);
243 s
= sizeof (union F
);
244 o
= __builtin_offsetof (union F
, f2
.d2
);
246 f2
= malloc (o
+ 212);
247 TS (f1
->f2
.d2
.b1
, s
- o
);
249 TS (f2
->f2
.d2
.b1
, s
- o
);
252 s
= sizeof (union F
);
253 o
= __builtin_offsetof (union F
, f2
.d2
);
255 f2
= malloc (o
+ 212);
256 TS (f1
->f2
.d2
.b2
.a1
, s
- o
);
258 TS (f2
->f2
.d2
.b2
.a1
, s
- o
);
261 s
= sizeof (union F
);
262 o
= __builtin_offsetof (union F
, f2
.d2
);
264 f2
= malloc (o
+ 212);
265 TF (f1
->f2
.d2
.b2
.a2
, s
- o
);
267 TF (f2
->f2
.d2
.b2
.a2
, s
- o
);
271 s
= sizeof (struct G
);
272 o
= __builtin_offsetof (struct G
, g2
);
273 struct G
*g1
= malloc (s
);
274 struct G
*g2
= malloc (o
+ 212);
280 s
= sizeof (struct G
);
281 o
= __builtin_offsetof (struct G
, g2
);
283 g2
= malloc (o
+ 212);
284 TA (g1
->g1
.a2
, s
, sizeof (g1
->g1
.a2
));
286 TA (g2
->g1
.a2
, s
, sizeof (g1
->g1
.a2
));
289 s
= sizeof (struct G
);
290 o
= __builtin_offsetof (struct G
, g2
);
292 g2
= malloc (o
+ 212);
299 s
= sizeof (struct H
);
300 o
= __builtin_offsetof (struct H
, h2
);
301 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
302 struct H
*h1
= malloc (s
);
303 struct H
*h2
= malloc (o2
+ 212);
309 s
= sizeof (struct H
);
310 o
= __builtin_offsetof (struct H
, h2
);
311 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
313 h2
= malloc (o2
+ 212);
314 TS (h1
->h2
.e1
.c1
, s
- o
);
316 TS (h2
->h2
.e1
.c1
, s
- o
);
319 s
= sizeof (struct H
);
320 o
= __builtin_offsetof (struct H
, h2
);
321 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
323 h2
= malloc (o2
+ 212);
324 TS (h1
->h2
.e1
.c2
.a1
, s
- o2
);
326 TS (h2
->h2
.e1
.c2
.a1
, s
- o2
);
329 s
= sizeof (struct H
);
330 o
= __builtin_offsetof (struct H
, h2
);
331 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
333 h2
= malloc (o2
+ 212);
334 TA (h1
->h2
.e1
.c2
.a2
, s
- o2
, sizeof (h1
->h2
.e1
.c2
.a2
));
336 TA (h2
->h2
.e1
.c2
.a2
, s
- o2
, sizeof (h2
->h2
.e1
.c2
.a2
));
339 s
= sizeof (struct H
);
340 o
= __builtin_offsetof (struct H
, h2
);
341 o2
= __builtin_offsetof (struct H
, h2
.e1
.c2
);
343 h2
= malloc (o2
+ 212);
344 TF (h1
->h2
.e2
, s
- o
);
346 TF (h2
->h2
.e2
, s
- o
);