blob: f134aaca0d6962fda2970396dbf36af9377ee05e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* { dg-do run } */
/* { dg-options "-O2" } */
typedef __SIZE_TYPE__ size_t;
extern void *malloc (size_t);
extern void free (void *);
extern void abort (void);
union U
{
struct S { int a; int b; } s;
int t;
};
struct T
{
int c;
char d[1];
};
int
main (void)
{
union U *u = malloc (sizeof (struct S) + sizeof (struct T) + 6);
struct T *t = (struct T *) (&u->s + 1);
if (__builtin_object_size (t->d, 1)
!= sizeof (struct T) + 6 - __builtin_offsetof (struct T, d))
abort ();
free (u);
return 0;
}
|