aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/delete8.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.other/delete8.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/delete8.C39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete8.C b/gcc/testsuite/g++.old-deja/g++.other/delete8.C
new file mode 100644
index 00000000000..1f884b70b53
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/delete8.C
@@ -0,0 +1,39 @@
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+#include <stdlib.h>
+
+struct S {
+ ~S ();
+};
+
+bool flag;
+S* s1;
+S* s2;
+
+void* operator new (size_t s)
+{
+ return malloc (s);
+}
+
+void operator delete (void* p)
+{
+ if (flag && p != s2)
+ abort ();
+}
+
+S::~S () {
+ if (this != s2)
+ abort ();
+ s1 = 0;
+}
+
+int main () {
+ s2 = new S;
+ s1 = s2;
+ // Turn on the check in `operator delete'.
+ flag = true;
+ delete s1;
+ // Turn it off again so that normal shutdown code works.
+ flag = false;
+}
+