Commit 2cf2b4f9 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

add tests for sized deallocation of size zero

Summary:
Sized deallocation via ::operator delete with size == 0 is
broken in some allocators.  This diff adds a unit test that ensures we
are either disabling sized deallocator or running with a good allocator.

Reviewed By: interwq

Differential Revision: D10857654

fbshipit-source-id: 981c7bcc1b021d4cd1ea1725ccf510d1958842fd
parent 202eace0
......@@ -41,6 +41,26 @@ TEST(allocateBytes, simple) {
deallocateBytes(p, 10);
}
TEST(allocateBytes, zero) {
auto p = allocateBytes(0);
deallocateBytes(p, 0);
}
TEST(operatorNewDelete, zero) {
auto p = ::operator new(0);
EXPECT_TRUE(p != nullptr);
::operator delete(p);
}
#if __cpp_sized_deallocation
TEST(operatorNewDelete, sized_zero) {
std::size_t n = 0;
auto p = ::operator new(n);
EXPECT_TRUE(p != nullptr);
::operator delete(p, n);
}
#endif
TEST(aligned_malloc, examples) {
auto trial = [](size_t align) {
auto const ptr = aligned_malloc(1, align);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment