1 // { dg-do run  }
2 // GROUPS passed temps
3 // temps file
4 // Message-Id: <9311171029.AA00592@mencon>
5 // From: gfm@mencon.mencon.oz.au (Graham Menhennitt)
6 // Subject: gcc 2.5.3 - bug deleting object that is still referred to
7 // Date: Wed, 17 Nov 93 21:29:23 EST
8 
9 #include        <stdio.h>
10 
11 class C {
12 public:
C(int i)13         C(int i) : val(i) { ; }
C(const C & c)14         C(const C& c) : val(c.val) { ; }
~C(void)15         ~C(void) { val = 999; }
16         C& operator = (const C& c) { val = c.val; return *this; }
17 
inc(int i)18         C& inc(int i) { val += i; return *this; }
19 
20         int val;
21 };
22 
23 C
f(void)24 f(void)
25 {
26         return C(3);
27 }
28 
29 C
f(int i)30 f(int i)
31 {
32         return f().inc(i);
33 }
34 
35 int
main(void)36 main(void)
37 {
38 	if (f (2).val != 5)
39 		{ printf ("FAIL\n"); return 1; }
40 	else
41 		printf ("PASS\n");
42 }
43