1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // test operator new replacement
12 // UNSUPPORTED: sanitizer-new-delete
22 void* operator new(std::size_t s) throw(std::bad_alloc)
25 void* ret = std::malloc(s);
26 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
30 void operator delete(void* p) throw()
36 bool A_constructed = false;
40 A() {A_constructed = true;}
41 ~A() {A_constructed = false;}
48 assert(A_constructed);
51 assert(!A_constructed);