Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/p9732b.C

raw
1 // { dg-do run }
2 // prms-id: 9732
3
4 int count;
5 int bail = 0;
6
7 extern "C" void abort (void);
8 extern "C" void _exit (int);
9
10
11 struct base {
12 base () { ++count; }
13 ~base () { --count; }
14 base(const base&o) { ++count; }
15 };
16
17 class D {
18 public:
19 ~D() {
20 if (bail++)
21 {
22 // On some Linux boxes, we run the dtor for d twice,
23 // once before exit, and once after!
24 abort ();
25 }
26 else
27 {
28 if (count != 0)
29 _exit (1);
30 _exit (0);
31 }
32 }
33 } d;
34
35 base base_object;
36
37 base base_returning_function ();
38
39 const base& base_ref = base_returning_function ();
40
41 int main () {
42 }
43
44 base base_returning_function () {
45 base local_base_object;
46 return local_base_object;
47 }