blob: 316041824c832277494c9e9a32b4cc59d54eb745 (
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
|
/* PR c++/94314. */
/* { dg-do run } */
/* { dg-options "-O2 --param early-inlining-insns=100 -fdump-tree-cddce-details -fdelete-null-pointer-checks" } */
volatile int idx;
struct base
{
__attribute__ ((malloc, noinline)) static void *
operator new (__SIZE_TYPE__ sz)
{
return ::operator new (sz);
}
__attribute__ ((noinline)) static void operator delete (void *ptr)
{
int c = count[idx];
count[idx] = c - 1;
::operator delete (ptr);
}
volatile static int count[2];
};
volatile int base::count[2] = {0, 0};
struct B : base
{
static void *operator new (__SIZE_TYPE__ sz)
{
int c = count[idx];
count[idx] = c + 1;
return base::operator new (sz);
}
};
volatile int c = 1;
int
main ()
{
for (int i = 0; i < c; i++)
{
idx = 0;
delete new B;
if (B::count[0] != 0)
__builtin_abort ();
}
return 0;
}
/* { dg-final { scan-tree-dump-not "Deleting : operator delete" "cddce1"} } */
|