aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/dtors3.C
blob: ce5aaf335f0ca685cdd7be00d71866c87a0e1d92 (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
34
35
36
37
// GROUPS passed destructors
// dtor file
// Message-Id: <9301242117.AA04053@cs.rice.edu>
// From: dougm@cs.rice.edu (Doug Moore)
// Subject: 2.3.3: premature dtor of temp?
// Date: Sun, 24 Jan 93 15:17:07 CST

#include <stdio.h>
#include <stdlib.h>

int killed = 0;

class Foo
{
  int a;
public:
  Foo() 
  :a(0) {;}
  ~Foo() { killed++;}
  Foo& operator << (int b)
  {
    a += b;
    if (killed)
      {
	printf ("FAIL\n");
	exit (0);
      }
    return *this;
  }
};

main()
{
  Foo() << 1 << 3 << 5 << 7;
  printf ("PASS\n");
}