1 /* { dg-do link } */
2 /* { dg-options "-O -fstrict-aliasing" } */
3 
4 class first
5 {
6 public:
7   double d;
8   int f1;
9 };
10 
11 class middle : public first
12 {
13 };
14 
15 class second : public middle
16 {
17 public:
18   int f2;
19   short a;
20 };
21 
22 class third
23 {
24 public:
25   char a;
26   char b;
27 };
28 
29 class multi: public third, public second
30 {
31 public:
32   short s;
33   /* The following field used to be of type char but that causes
34      class multi to effectively get alias-set zero which we end
35      up not optimizing because of the fix for PR44164.  */
36   int f3;
37 };
38 
39 extern void link_error ();
40 
41 void
foo(first * s1,second * s2)42 foo (first *s1, second *s2)
43 {
44   s1->f1 = 0;
45   s2->f2 = 0;
46   s1->f1++;
47   s2->f2++;
48   s1->f1++;
49   s2->f2++;
50   if (s1->f1 != 2)
51     link_error ();
52 }
53 
54 void
bar(first * s1,multi * s3)55 bar (first *s1, multi *s3)
56 {
57   s1->f1 = 0;
58   s3->f3 = 0;
59   s1->f1++;
60   s3->f3++;
61   s1->f1++;
62   s3->f3++;
63   if (s1->f1 != 2)
64     link_error ();
65 }
66 
67 
68 int
main()69 main()
70 {
71   first a;
72   second b;
73   multi c;
74   foo (&a, &b);
75   bar (&a, &c);
76   return 0;
77 }
78