| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O -fstrict-aliasing -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
struct S { float f; int i; }; |
| 5 |
struct R { int x; int i; }; |
| 6 |
|
| 7 |
/* Strict-aliasing rules say that int and float do not alias. */ |
| 8 |
int bar(struct S *s, int *i) |
| 9 |
{ |
| 10 |
*i = 0; |
| 11 |
s->f = 1.0; |
| 12 |
return *i; |
| 13 |
} |
| 14 |
|
| 15 |
/* Strict-aliasing rules say that S and R do not alias. */ |
| 16 |
int foo(struct S *s, struct R *r) |
| 17 |
{ |
| 18 |
r->i = 0; |
| 19 |
s->i = 1; |
| 20 |
return r->i; |
| 21 |
} |
| 22 |
|
| 23 |
/* { dg-final { scan-tree-dump-times "return 0;" 2 "optimized" } } */ |