Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / torture / pr117341-1.C
blobb13d2502e3512847872fdac90d266ae6b9739e3d
1 void swap(long &a, long &b)
3   long t = a;
4   a = b;
5   b = t;
8 struct Array {
9     long arr[1];
10     Array() : arr() {}
11     /* Operators */
12     long& operator[](int index) { return arr[index]; }
13     const long& operator[](int index) const { return arr[index]; }
14     /* Operations */
15     void swap(Array& array)  {
16         for (int i = 0; i < 1; ++i)
17             ::swap(arr[i], array[i]);
18     }
21 class Vector : public Array {};
23 struct v
25   Vector *e;
26   v() : e (new Vector[4]){}
27   Vector& operator[](int index) { return e[index]; }
28   const Vector& operator[](int index) const { return e[index]; }
30 static inline Vector func(const Vector& y)
32         return y;
35 volatile int a;
37 int main() {
38     v solution;
39     solution[0][0] = 1;
40     int t = a;
41     for (int i = 0; i < 3; ++i) {
42         const Vector& v = solution[i];
43         Vector sum;
44         const long delta = func(v)[0] & t;
45         sum[0] = v[0] + delta;
46         solution[i + 1].swap(sum);
47     }
48     for(int i = 0; i < 4; i++)
49     {
50       if (solution[i][0] != 1)
51         __builtin_abort();
52     }
53     return 0;