Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / torture / pr106131.C
blobe110f4a8fe603fca1c1c8e3b56b79eec01d4ccf0
1 // { dg-do run { target c++11 } }
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     }
14 const int &max(const int &a, const int &b)
16   return a < b ? b : a;
19 int foo(Pair x, Pair y)
21   return max(x.b, y.b);
24 int main()
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   }