* init.c (build_delete): Create a SAVE_EXPR for the address if
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / delete8.C
blob1f884b70b53c05722a3fb300bb9348ee42998b4b
1 // Origin: Mark Mitchell <mark@codesourcery.com>
3 #include <stdlib.h>
5 struct S {
6   ~S ();
7 };
9 bool flag;
10 S* s1;
11 S* s2;
13 void* operator new (size_t s)
15   return malloc (s);
18 void operator delete (void* p)
20   if (flag && p != s2)
21     abort ();
24 S::~S () { 
25   if (this != s2)
26     abort ();
27   s1 = 0;
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;