summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/pr19317-1.C
blob: ffb646a9097c2461e2eecbe58b1710969703548d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// PR c++/19317
// { dg-options "-O2" }
// { dg-do run }
// Origin: Dirk Mueller <mueller@kde.org>

extern "C" void abort (void);

struct A
{
  A () { d = e = 0; f = -1; }
  A (int x) : d (0), e (0), f (x) { }
  A b (const A &r) const;
  int d;
  int e;
  int f;
};

A
A::b (const A & r) const
{
  A t;
  t.f = f < r.f ? f : r.f;
  return t;
}

int
main ()
{
  A a (100);
  a = a.b (A (10));
  if (a.f != 10)
    abort ();

  A c (10);
  A d (100);
  c = d.b (c);
  if (c.f != 10)
    abort ();
}