Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr117341-1.C

raw
1 void swap(long &a, long &b)
2 {
3 long t = a;
4 a = b;
5 b = t;
6 }
7
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 }
19 };
20
21 class Vector : public Array {};
22
23 struct v
24 {
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]; }
29 };
30 static inline Vector func(const Vector& y)
31 {
32 return y;
33 }
34
35 volatile int a;
36
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;
54 }