aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/dtors5.C
blob: 9aa2e6d79ec9a731dddb4042c70750ad60b631f8 (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
// GROUPS passed destructors
// dtor file:
// Message-Id: <1992Jun25.181845.18886@leland.Stanford.EDU>
// From: niz@leland.stanford.edu (Jim Nisbet)
// Subject: gcc 2.2.2 -- c++ bug: destructor called twice (example)
// Date: 25 Jun 92 18:18:45 GMT

#include <stdio.h>

int things = 0;

class foo {
public:
   foo() { things++; }
   foo(const foo&) { things++; }
   ~foo() { things--; }

   int i;
};

void
sub(foo f) {
   ;
};


main() {
   sub(foo());
   if (things == 0)
     printf ("PASS\n");
   else
     printf ("FAIL\n");
}