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 [] nothrow by replacing only operator new
12 // UNSUPPORTED: sanitizer-new-delete
14 // TODO Investigate why UBSAN prevents new from calling our replacement.
26 void* operator new(std::size_t s) throw(std::bad_alloc)
29 void* ret = std::malloc(s);
30 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
34 void operator delete(void* p) throw()
40 volatile int A_constructed = 0;
44 A() {++A_constructed;}
45 ~A() {--A_constructed;}
50 A* ap = new (std::nothrow) A[3];
52 assert(A_constructed == 3);
55 assert(A_constructed == 0);