Debian Codegraph @

gcc/testsuite/g++.dg/torture/pr106131.C

raw
1 // { dg-do run { target c++11 } }
2
3 struct Pair {
4 int a, b;
5 Pair(const Pair &) = default;
6 Pair(int _a, int _b) : a(_a), b(_b) {}
7 Pair &operator=(const Pair &z) {
8 a = z.a;
9 b = z.b;
10 return *this;
11 }
12 };
13
14 const int &max(const int &a, const int &b)
15 {
16 return a < b ? b : a;
17 }
18
19 int foo(Pair x, Pair y)
20 {
21 return max(x.b, y.b);
22 }
23
24 int main()
25 {
26 auto f = new Pair[3] {{0, -11}, {0, -8}, {0, 2}};
27 for (int i = 0; i < 1; i++) {
28 f[i] = f[0];
29 if(i == 0)
30 f[i] = f[2];
31 if (foo(f[i], f[1]) != 2)
32 __builtin_abort();
33 }
34 }