From 7e672ca106b3d317fe2dfa1aafe34c1c27c3a561 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 30 May 2025 12:52:37 -0400 Subject: [PATCH] tests: support C++23 in tests Signed-off-by: Henry Schreiner --- tests/pure_cpp/smart_holder_poc_test.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/pure_cpp/smart_holder_poc_test.cpp b/tests/pure_cpp/smart_holder_poc_test.cpp index 0d3057b31..55018e65b 100644 --- a/tests/pure_cpp/smart_holder_poc_test.cpp +++ b/tests/pure_cpp/smart_holder_poc_test.cpp @@ -1,5 +1,6 @@ #include "smart_holder_poc.h" +#include #include #include #include @@ -380,8 +381,17 @@ TEST_CASE("error_cannot_disown_nullptr", "[E]") { TEST_CASE("indestructible_int-from_raw_ptr_unowned+as_raw_ptr_unowned", "[S]") { using zombie = helpers::indestructible_int; + +// This is from C++17 +#ifdef __cpp_lib_byte + using raw_byte = std::byte; +#else + using raw_byte = char; +#endif + // Using placement new instead of plain new, to not trigger leak sanitizer errors. - static std::aligned_storage::type memory_block[1]; + alignas(zombie) raw_byte memory_block[sizeof(zombie)]; + auto *value = new (memory_block) zombie(19); auto hld = smart_holder::from_raw_ptr_unowned(value); REQUIRE(hld.as_raw_ptr_unowned()->valu == 19);