]> gcc.gnu.org Git - gcc.git/commitdiff
New test case.
authorMartin v. Löwis <loewis@gcc.gnu.org>
Fri, 14 Jan 2000 23:43:19 +0000 (23:43 +0000)
committerMartin v. Löwis <loewis@gcc.gnu.org>
Fri, 14 Jan 2000 23:43:19 +0000 (23:43 +0000)
From-SVN: r31432

gcc/testsuite/g++.old-deja/g++.ns/new1.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.old-deja/g++.ns/new1.C b/gcc/testsuite/g++.old-deja/g++.ns/new1.C
new file mode 100644 (file)
index 0000000..9ffd247
--- /dev/null
@@ -0,0 +1,33 @@
+// Test whether N::operator new is different from ::operator new
+#include <new>
+#include <cstdlib>
+
+bool success;
+
+namespace N{
+  void* operator new(size_t n){
+    success = true;
+    return std::malloc(n);
+  }
+}
+
+void *operator new(size_t n)throw(std::bad_alloc)
+{
+  static bool entered = false;
+  if(entered)
+    throw std::bad_alloc();
+  entered = true;
+  void *result = N::operator new(n);
+  entered = false;
+  return result;
+}
+
+int main()
+{
+  try{
+    new int;
+  }catch(...){
+    return 1;
+  }
+  return success?0:1;
+}
This page took 0.071313 seconds and 5 git commands to generate.