| 1 |
/* { dg-do run } |
| 2 |
* { dg-options "-std=c23 -O2" } */ |
| 3 |
|
| 4 |
[[gnu::noinline]] |
| 5 |
void *alias(void *ap, void *bp, void *x, void *y) |
| 6 |
{ |
| 7 |
struct foo { struct bar *f; } *a = ap; |
| 8 |
struct bar { long x; }; |
| 9 |
|
| 10 |
a->f = x; |
| 11 |
|
| 12 |
{ |
| 13 |
struct bar; |
| 14 |
struct foo { struct bar *f; } *b = bp; |
| 15 |
struct bar { long x; }; |
| 16 |
|
| 17 |
// after completing bar, the two struct foo should be compatible |
| 18 |
|
| 19 |
b->f = y; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
return a->f; |
| 24 |
} |
| 25 |
|
| 26 |
int main() |
| 27 |
{ |
| 28 |
struct bar { long x; }; |
| 29 |
struct foo { struct bar *f; } a; |
| 30 |
struct bar x, y; |
| 31 |
if (&y != alias(&a, &a, &x, &y)) |
| 32 |
__builtin_abort(); |
| 33 |
|
| 34 |
return 0; |
| 35 |
} |
| 36 |
|