blob: c81ae7571ca0310c9fd8d7c0111d9413d14da45d (
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
|
// { dg-do run }
// prms-id: 4246
extern "C" void abort ();
int num_d;
class A
{
public:
A() { }
virtual ~A() { }
virtual void id() { }
};
class B
{
public:
B() { }
virtual ~B() { }
virtual void id() { }
};
class C : public A, public B
{
public:
C() { }
virtual ~C() { }
void id() { abort(); }
};
class D : public C
{
public:
D() { ++num_d; }
virtual ~D() { -- num_d; }
void id() { }
};
int main()
{
D* dp2 = new D;
((B*)dp2)->id();
delete (B*) dp2;
B* bp1 = new D;
bp1->id();
delete bp1;
return num_d != 0;
}
|