1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wall" } */
3
4 struct g { long a; };
5 unsigned long f(struct g *a) { return *(unsigned long *)&a->a; }
6
7 struct A
8 {
9 void *a;
10 };
11
12 int g(const struct A *x, long *y)
13 {
14 typedef long __attribute__ ((may_alias)) long_a;
15 *y = *(const long_a *) (&x->a);
16 return 1;
17 }
18
19 void *a;
20
21 int
22 f0 (long *y)
23 {
24 *y = *(const long *) &a; /* { dg-warning "will break" } */
25 return 1;
26 }
27
28 int
29 f1 (long *y)
30 {
31 typedef long __attribute__ ((may_alias)) long_a;
32 *y = *(const long_a *) &a;
33 return 1;
34 }
35
36 int
37 f2 (long *y)
38 {
39 *y = *(const long *) &a; /* { dg-warning "will break" } */
40 return 1;
41 }