blob: 924bf4a0bac81fe8737c3895592ab756e2f0c0d2 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// { dg-do run }
// GROUPS passed destructors
// Check that virtual destructors work correctly. Specifically,
// check that when you destruct an object of a derived class for
// which the base class had an explicitly declared virtual destructor
// no infinite recursion occurs.
//
// Bug description:
// The generated g++ code apparently calls the base class destructor via
// the virtual table, rather than directly. This, of course, results in the
// infinite recursion.
extern "C" int printf (const char *, ...);
int errors = 0;
struct base {
int member;
base();
virtual ~base();
};
base::base()
{
}
base::~base()
{
}
struct derived : public base
{
int member;
derived();
~derived();
};
derived::derived() : base()
{
}
int derived_destructor_calls = 0;
extern void exit (int);
derived::~derived()
{
if (++derived_destructor_calls > 2)
errors++;
}
void test ();
int main ()
{
test ();
if (errors)
{ printf ("FAIL\n"); return 1; }
else
printf ("PASS\n");
return 0;
}
base* bp;
void test()
{
derived a;
a.member = 99;
bp = new derived;
delete bp;
}
|