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
* init.c (build_delete): Create a SAVE_EXPR for the address if
[official-gcc.git]
/
gcc
/
testsuite
/
g++.old-deja
/
g++.other
/
delete8.C
blob
1f884b70b53c05722a3fb300bb9348ee42998b4b
1
// Origin: Mark Mitchell <mark@codesourcery.com>
2
3
#include <stdlib.h>
4
5
struct S {
6
~S ();
7
};
8
9
bool flag;
10
S* s1;
11
S* s2;
12
13
void* operator new (size_t s)
14
{
15
return malloc (s);
16
}
17
18
void operator delete (void* p)
19
{
20
if (flag && p != s2)
21
abort ();
22
}
23
24
S::~S () {
25
if (this != s2)
26
abort ();
27
s1 = 0;
28
}
29
30
int main () {
31
s2 = new S;
32
s1 = s2;
33
// Turn on the check in `operator delete'.
34
flag = true;
35
delete s1;
36
// Turn it off again so that normal shutdown code works.
37
flag = false;
38
}
39