1*c87b03e5Sespie // GROUPS passed destructors
2*c87b03e5Sespie // dtor file:
3*c87b03e5Sespie // Message-Id: <1992Jun25.181845.18886@leland.Stanford.EDU>
4*c87b03e5Sespie // From: niz@leland.stanford.edu (Jim Nisbet)
5*c87b03e5Sespie // Subject: gcc 2.2.2 -- c++ bug: destructor called twice (example)
6*c87b03e5Sespie // Date: 25 Jun 92 18:18:45 GMT
7*c87b03e5Sespie 
8*c87b03e5Sespie #include <stdio.h>
9*c87b03e5Sespie 
10*c87b03e5Sespie int things = 0;
11*c87b03e5Sespie 
12*c87b03e5Sespie class foo {
13*c87b03e5Sespie public:
foo()14*c87b03e5Sespie    foo() { things++; }
foo(const foo &)15*c87b03e5Sespie    foo(const foo&) { things++; }
~foo()16*c87b03e5Sespie    ~foo() { things--; }
17*c87b03e5Sespie 
18*c87b03e5Sespie    int i;
19*c87b03e5Sespie };
20*c87b03e5Sespie 
21*c87b03e5Sespie void
sub(foo f)22*c87b03e5Sespie sub(foo f) {
23*c87b03e5Sespie    ;
24*c87b03e5Sespie };
25*c87b03e5Sespie 
26*c87b03e5Sespie 
main()27*c87b03e5Sespie int main() {
28*c87b03e5Sespie    sub(foo());
29*c87b03e5Sespie    if (things == 0)
30*c87b03e5Sespie      printf ("PASS\n");
31*c87b03e5Sespie    else
32*c87b03e5Sespie      { printf ("FAIL\n"); return 1; }
33*c87b03e5Sespie }
34