summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/temps5.C
blob: e33962e1c44e1bfd1f0ed330a5309fccd4f50970 (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
38
39
40
41
42
// { dg-do run  }
// GROUPS passed temps
// temps file
// Message-Id: <9311171029.AA00592@mencon>
// From: gfm@mencon.mencon.oz.au (Graham Menhennitt)
// Subject: gcc 2.5.3 - bug deleting object that is still referred to
// Date: Wed, 17 Nov 93 21:29:23 EST

#include        <stdio.h>

class C {
public:
        C(int i) : val(i) { ; }
        C(const C& c) : val(c.val) { ; }
        ~C(void) { val = 999; }
        C& operator = (const C& c) { val = c.val; return *this; }

        C& inc(int i) { val += i; return *this; }

        int val;
};

C
f(void)
{
        return C(3);
}

C
f(int i)
{
        return f().inc(i);
}

int
main(void)
{
	if (f (2).val != 5)
		{ printf ("FAIL\n"); return 1; }
	else
		printf ("PASS\n");
}