| 1 |
/* PR c++/94314. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2 --param early-inlining-insns=100 -fdump-tree-cddce-details -fdelete-null-pointer-checks" } */ |
| 4 |
|
| 5 |
volatile int idx; |
| 6 |
|
| 7 |
struct base |
| 8 |
{ |
| 9 |
__attribute__ ((malloc, noinline)) static void * |
| 10 |
operator new (__SIZE_TYPE__ sz) |
| 11 |
{ |
| 12 |
return ::operator new (sz); |
| 13 |
} |
| 14 |
|
| 15 |
__attribute__ ((noinline)) static void operator delete (void *ptr) |
| 16 |
{ |
| 17 |
int c = count[idx]; |
| 18 |
count[idx] = c - 1; |
| 19 |
::operator delete (ptr); |
| 20 |
} |
| 21 |
volatile static int count[2]; |
| 22 |
}; |
| 23 |
|
| 24 |
volatile int base::count[2] = {0, 0}; |
| 25 |
|
| 26 |
struct B : base |
| 27 |
{ |
| 28 |
static void *operator new (__SIZE_TYPE__ sz) |
| 29 |
{ |
| 30 |
int c = count[idx]; |
| 31 |
count[idx] = c + 1; |
| 32 |
return base::operator new (sz); |
| 33 |
} |
| 34 |
}; |
| 35 |
|
| 36 |
volatile int c = 1; |
| 37 |
|
| 38 |
int |
| 39 |
main () |
| 40 |
{ |
| 41 |
for (int i = 0; i < c; i++) |
| 42 |
{ |
| 43 |
idx = 0; |
| 44 |
delete new B; |
| 45 |
if (B::count[0] != 0) |
| 46 |
__builtin_abort (); |
| 47 |
} |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|
| 52 |
/* { dg-final { scan-tree-dump-not "Deleting : operator delete" "cddce1"} } */ |