1 /* { dg-do compile } */
2 /* { dg-options "-O -fdump-tree-ccp1" } */
3 
foo(void)4 int foo(void)
5 {
6   int i = 0;
7   char *p = (char *)&i;
8   return *(int *)p;
9 }
10 
11 struct Foo {
12   int i;
13 } f;
14 
bar(void)15 int bar(void)
16 {
17   char *p = (char *)&f;
18   return ((struct Foo *)p)->i;
19 }
20 
21 extern const struct Foo g;
22 
foobar(void)23 int foobar(void)
24 {
25   struct Foo *p = (struct Foo *)&g;
26   return ((const struct Foo *)p)->i;
27 }
28 
29 /* { dg-final { scan-tree-dump "= i_.;" "ccp1" } } */
30 /* { dg-final { scan-tree-dump "= f.i;" "ccp1" } } */
31 /* { dg-final { scan-tree-dump "= g.i;" "ccp1" } } */
32