aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C
blob: 97ce95a81c0cdfe25a280bc63ec463644263d069 (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
// Bug: g++ initializes both B::i and B::j before destroying any temps.

extern "C" int printf (const char *, ...);

int c = 0;
int d = 0;
int r = 0;

struct A {
  A() { if (c != d) r = 1; ++c; }
  A(const A&);  // declare so g++ returns A on the stack
  ~A() { ++d; }
  operator int () { return 0; }
};

A foo ()
{
  return A();
}

struct B {
  int i;
  int j;
  B(): i(foo()), j(foo()) { }
};

main()
{
  B b;
  return r;
}