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)
12 // asan and msan will not call the new handler.
13 // UNSUPPORTED: sanitizer-new-delete
20 #include "test_macros.h"
22 int new_handler_called = 0;
27 std::set_new_handler(0);
30 bool A_constructed = false;
34 A() {A_constructed = true;}
35 ~A() {A_constructed = false;}
40 std::set_new_handler(new_handler);
41 #ifndef TEST_HAS_NO_EXCEPTIONS
45 void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
46 assert(new_handler_called == 1);
49 #ifndef TEST_HAS_NO_EXCEPTIONS
55 A* ap = new(std::nothrow) A;
57 assert(A_constructed);
59 assert(!A_constructed);