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 sized operator [] delete calls the unsized operator [] delete.
11 // When sized operator delete [] is not available (ex C++11) then the unsized
12 // operator delete [] is called directly.
14 // UNSUPPORTED: sanitizer-new-delete
21 #include "test_macros.h"
23 int delete_called = 0;
24 int delete_nothrow_called = 0;
26 void operator delete[](void* p) TEST_NOEXCEPT
32 void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
34 ++delete_nothrow_called;
38 // NOTE: Use a class with a non-trivial destructor as the test type in order
39 // to ensure the correct overload is called.
40 // C++14 5.3.5 [expr.delete]p10
41 // - If the type is complete and if, for the second alternative (delete array)
42 // only, the operand is a pointer to a class type with a non-trivial
43 // destructor or a (possibly multi-dimensional) array thereof, the function
44 // with two parameters is selected.
45 // - Otherwise, it is unspecified which of the two deallocation functions is
52 assert(0 == delete_called);
53 assert(0 == delete_nothrow_called);
56 assert(1 == delete_called);
57 assert(0 == delete_nothrow_called);