From 1c834112f27adc8b9372e3cb8ebd39e827d3c7cd Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 7 Jul 2023 13:37:27 -0400 Subject: [PATCH] [libc++] Add some tests for std::bit_cast using pointers Differential Revision: https://reviews.llvm.org/D154728 --- .../numerics/bit/bit.cast/bit_cast.pass.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp b/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp index fe1e3063c5a9..f73877416a71 100644 --- a/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp +++ b/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp @@ -239,6 +239,28 @@ bool tests() { #endif } + // Test pointers + { + { + int obj = 3; + void* p = &obj; + test_roundtrip_through_nested_T(p); + test_roundtrip_through_buffer(p); + test_roundtrip_through(p); + test_roundtrip_through(p); + test_roundtrip_through(p); + } + { + int obj = 3; + int* p = &obj; + test_roundtrip_through_nested_T(p); + test_roundtrip_through_buffer(p); + test_roundtrip_through(p); + test_roundtrip_through(p); + test_roundtrip_through(p); + } + } + return true; }