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