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
20 #include "test_macros.h"
24 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
27 void* ret = std::malloc(s);
28 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
32 void operator delete(void* p) TEST_NOEXCEPT
38 volatile int A_constructed = 0;
42 A() {++A_constructed;}
43 ~A() {--A_constructed;}
50 ap = new (std::nothrow) A[3];
52 assert(A_constructed == 3);
55 assert(A_constructed == 0);