| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Wstrict-aliasing=1 -fstrict-aliasing" } */ |
| 3 |
|
| 4 |
struct incomplete; |
| 5 |
struct s1 { int i; }; |
| 6 |
struct s2 { double d; }; |
| 7 |
|
| 8 |
void |
| 9 |
f (int *i, double *d, struct s1 *s1, struct s2 *s2, char *c) |
| 10 |
{ |
| 11 |
(char *) i; |
| 12 |
(char *) d; |
| 13 |
(char *) s1; |
| 14 |
(char *) s2; |
| 15 |
(char *) c; |
| 16 |
|
| 17 |
(int *) i; |
| 18 |
(int *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 19 |
(int *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 20 |
(int *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 21 |
(int *) c; |
| 22 |
|
| 23 |
(double *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 24 |
(double *) d; |
| 25 |
(double *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 26 |
(double *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 27 |
(double *) c; |
| 28 |
|
| 29 |
(struct incomplete *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 30 |
(struct incomplete *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 31 |
(struct incomplete *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 32 |
(struct incomplete *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 33 |
(struct incomplete *) c; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 34 |
|
| 35 |
(struct s1 *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 36 |
(struct s1 *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 37 |
(struct s1 *) s1; |
| 38 |
(struct s1 *) s2; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 39 |
(struct s1 *) c; |
| 40 |
|
| 41 |
(struct s2 *) i; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 42 |
(struct s2 *) d; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 43 |
(struct s2 *) s1; /* { dg-warning "dereferencing type-punned pointer might break strict-aliasing rules" } */ |
| 44 |
(struct s2 *) s2; |
| 45 |
(struct s2 *) c; |
| 46 |
} |