diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -38,13 +37,13 @@ typedef default_constructible T; typedef std::pair P; typedef std::pmr::polymorphic_allocator A; - P* ptr = (P*)std::malloc(sizeof(P)); + alignas(P) char buffer[sizeof(P)]; + P* ptr = reinterpret_cast(buffer); A a; a.construct(ptr); assert(constructed == 2); assert(ptr->first.x == 42); assert(ptr->second.x == 42); - std::free(ptr); } return 0; diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair_evil.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair_evil.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair_evil.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_piecewise_pair_evil.pass.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "test_macros.h" @@ -105,13 +104,12 @@ PMA pma(std::pmr::new_delete_resource()); { using Pair = std::pair; - void* where = std::malloc(sizeof(Pair)); - Pair* p = (Pair*)where; + alignas(Pair) char buffer[sizeof(Pair)]; + Pair* p = reinterpret_cast(buffer); pma.construct(p, std::piecewise_construct, std::make_tuple(42), std::make_tuple(42)); assert(p->first.holds(42, pma)); assert(p->second.holds(42, pma)); pma.destroy(p); - std::free(where); } } diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/destroy.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/destroy.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/destroy.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/destroy.pass.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -39,11 +38,11 @@ ASSERT_SAME_TYPE(decltype(a.destroy((destroyable*)nullptr)), void); } { - destroyable* ptr = ::new (std::malloc(sizeof(destroyable))) destroyable(); + alignas(destroyable) char buffer[sizeof(destroyable)]; + destroyable* ptr = ::new (buffer) destroyable(); assert(count == 1); A{}.destroy(ptr); assert(count == 0); - std::free(ptr); } return 0;