gcc/testsuite/gcc.dg/c23-tag-alias-4.c
raw| 1 | /* { dg-do run } |
| 2 | * { dg-options "-std=c23 -O2" } |
| 3 | */ |
| 4 | |
| 5 | |
| 6 | /* Here we check that structs with flexible array |
| 7 | * members can alias a compatible redefinition. */ |
| 8 | |
| 9 | struct bar { int x; int f[]; }; |
| 10 | |
| 11 | int test_bar1(struct bar* a, void* b) |
| 12 | { |
| 13 | a->x = 1; |
| 14 | |
| 15 | struct bar { int x; int f[]; }* p = b; |
| 16 | struct bar* q = a; |
| 17 | p->x = 2; |
| 18 | |
| 19 | return a->x; |
| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | struct bar z; |
| 25 | |
| 26 | if (2 != test_bar1(&z, &z)) |
| 27 | __builtin_abort(); |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 |