1 /* { dg-do run } */ 2 /* { dg-options "-O -fno-strict-aliasing" } */ 3 4 struct S 5 { 6 void *a; 7 long double b; 8 }; 9 10 struct Z 11 { 12 long long l; 13 short s; 14 } __attribute__((packed)); 15 16 struct S __attribute__((noclone, noinline)) foo(void * v,struct Z * z)17foo (void *v, struct Z *z) 18 { 19 struct S t; 20 t.a = v; 21 *(struct Z *) &t.b = *z; 22 return t; 23 } 24 25 struct Z gz; 26 27 int main(int argc,char ** argv)28main (int argc, char **argv) 29 { 30 struct S s; 31 32 if (sizeof (long double) < sizeof (struct Z)) 33 return 0; 34 35 gz.l = 0xbeef; 36 gz.s = 0xab; 37 38 s = foo ((void *) 0, &gz); 39 40 if ((((struct Z *) &s.b)->l != gz.l) 41 || (((struct Z *) &s.b)->s != gz.s)) 42 __builtin_abort (); 43 return 0; 44 } 45