repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git]
/
gcc
/
testsuite
/
g++.old-deja
/
g++.other
/
delete8.C
blob
ea44445b0b6c06b63c0256df3d09ce69c7bceb0b
1
// { dg-do run }
2
// Origin: Mark Mitchell <mark@codesourcery.com>
3
4
#include <stdlib.h>
5
6
struct S {
7
~S ();
8
};
9
10
bool flag;
11
S* s1;
12
S* s2;
13
14
void* operator new (size_t s)
15
{
16
return malloc (s);
17
}
18
19
void operator delete (void* p)
20
{
21
if (flag && p != s2)
22
abort ();
23
}
24
25
S::~S () {
26
if (this != s2)
27
abort ();
28
s1 = 0;
29
}
30
31
int main () {
32
s2 = new S;
33
s1 = s2;
34
// Turn on the check in `operator delete'.
35
flag = true;
36
delete s1;
37
// Turn it off again so that normal shutdown code works.
38
flag = false;
39
}
40