summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/pr15054-2.C
blob: 156e945d01135718e18484b99d7a434136435c4a (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 middle-end/15054

// { dg-do run }
// { dg-options "-O2" }

extern "C" void abort (void);

void
__attribute__((noinline))
check (long x, long y)
{
  if (x != y)
    abort ();
}

struct A
{
  A() : a(2) { check (a, 2); }
  ~A() { check (a, 2); }
private:
  long a;
};

class B {
  long b;
  B& operator =(const B& );
public:
  B (long p) : b(p) { check (b, 6); }
  B (const B& p) : b(p.b) { check (b, 6); }
  ~B () { check (b, 6); A obj; check (b, 6); }
  B foo() { return B(*this); }
};

int main ()
{
  B o(6);
  o.foo().foo();
  return 0;
}