1 // PR tree-optimization/32353
2 // { dg-do run }
3 // { dg-options "-O2" }
4
5 extern "C" void abort ();
6
7 struct A
8 {
9 int f;
AA10 A (int x) : f (x) {}
11 };
12
13 A
foo(const A & x,const A & y)14 foo (const A &x, const A &y)
15 {
16 A r (0);
17 r = x.f == -111 ? y : (y.f == -111 || x.f > y.f) ? x : y;
18 A s (0);
19 r = r.f == -111 ? s : (r.f > s.f) ? r : s;
20 return r;
21 }
22
23 int
main()24 main ()
25 {
26 if (foo (A (0), A (1)).f != 1)
27 abort ();
28 if (foo (A (1), A (9)).f != 9)
29 abort ();
30 if (foo (A (9), A (1)).f != 9)
31 abort ();
32 if (foo (A (-4), A (-5)).f != 0)
33 abort ();
34 if (foo (A (-111), A (-111)).f != 0)
35 abort ();
36 if (foo (A (2), A (-111)).f != 2)
37 abort ();
38 if (foo (A (-111), A (6)).f != 6)
39 abort ();
40 if (foo (A (-111), A (-4)).f != 0)
41 abort ();
42 }
43