| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-std=c2y -O2" } */ |
| 3 |
|
| 4 |
struct f2 { |
| 5 |
struct f { |
| 6 |
_Alignas(int) char buf[sizeof(int)]; |
| 7 |
} x[2]; |
| 8 |
int i; |
| 9 |
}; |
| 10 |
|
| 11 |
[[gnu::noinline]] |
| 12 |
int foo2(struct f2 *p, int *q) |
| 13 |
{ |
| 14 |
*q = 1; |
| 15 |
*p = (struct f2){ }; |
| 16 |
return *q; |
| 17 |
} |
| 18 |
|
| 19 |
struct g2 { |
| 20 |
union g { |
| 21 |
_Alignas(int) char buf[sizeof(int)]; |
| 22 |
} x[2]; |
| 23 |
int i; |
| 24 |
}; |
| 25 |
|
| 26 |
[[gnu::noinline]] |
| 27 |
int bar2(struct g2 *p, int *q) |
| 28 |
{ |
| 29 |
*q = 1; |
| 30 |
*p = (struct g2){ }; |
| 31 |
return *q; |
| 32 |
} |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
struct f2 p2; |
| 37 |
if (0 != foo2(&p2, (void*)&p2.x[0].buf)) |
| 38 |
__builtin_abort(); |
| 39 |
|
| 40 |
struct g2 q2; |
| 41 |
if (0 != bar2(&q2, (void*)&q2.x[0].buf)) |
| 42 |
__builtin_abort(); |
| 43 |
} |