2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / delete8.C
blobea44445b0b6c06b63c0256df3d09ce69c7bceb0b
1 // { dg-do run  }
2 // Origin: Mark Mitchell <mark@codesourcery.com>
4 #include <stdlib.h>
6 struct S {
7   ~S ();
8 };
10 bool flag;
11 S* s1;
12 S* s2;
14 void* operator new (size_t s)
16   return malloc (s);
19 void operator delete (void* p)
21   if (flag && p != s2)
22     abort ();
25 S::~S () { 
26   if (this != s2)
27     abort ();
28   s1 = 0;
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;