OSDN Git Service
(root)
/
pf3gnuchains
/
gcc-fork.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git]
/
gcc
/
testsuite
/
g++.old-deja
/
g++.other
/
delete8.C
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