Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.jason/temporary4.C

raw
1 // { dg-do run }
2 // Bug: g++ initializes both B::i and B::j before destroying any temps.
3
4 extern "C" int printf (const char *, ...);
5
6 int c = 0;
7 int d = 0;
8 int r = 0;
9
10 struct A {
11 A() { if (c != d) r = 1; ++c; }
12 A(const A&); // declare so g++ returns A on the stack
13 ~A() { ++d; }
14 operator int () { return 0; }
15 };
16
17 A foo ()
18 {
19 return A();
20 }
21
22 struct B {
23 int i;
24 int j;
25 B(): i(foo()), j(foo()) { }
26 };
27
28 int main()
29 {
30 B b;
31 return r;
32 }