diff options
Diffstat (limited to 'libcxx/test')
3 files changed, 12 insertions, 9 deletions
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp index 490fdf5d332..ab8179c5ab4 100644 --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp @@ -17,6 +17,7 @@ // }; #include <memory> +#include <cstdint> #include <cassert> template <class T> @@ -27,12 +28,12 @@ struct A value_type* allocate(std::size_t n) { assert(n == 10); - return (value_type*)0xDEADBEEF; + return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF)); } }; int main() { A<int> a; - assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF); + assert(std::allocator_traits<A<int> >::allocate(a, 10) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF))); } diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp index 079db3526ac..71f39d8deeb 100644 --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp @@ -17,6 +17,7 @@ // }; #include <memory> +#include <cstdint> #include <cassert> template <class T> @@ -27,7 +28,7 @@ struct A value_type* allocate(std::size_t n) { assert(n == 10); - return (value_type*)0xDEADBEEF; + return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF)); } }; @@ -39,13 +40,13 @@ struct B value_type* allocate(std::size_t n) { assert(n == 12); - return (value_type*)0xEEADBEEF; + return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xEEADBEEF)); } value_type* allocate(std::size_t n, const void* p) { assert(n == 11); assert(p == 0); - return (value_type*)0xFEADBEEF; + return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xFEADBEEF)); } }; @@ -53,8 +54,8 @@ int main() { #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE A<int> a; - assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF); + assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF))); #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE B<int> b; - assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF); + assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xFEADBEEF))); } diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp index b137dc6d36c..8176d8b3767 100644 --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp @@ -17,6 +17,7 @@ // }; #include <memory> +#include <cstdint> #include <cassert> int called = 0; @@ -28,7 +29,7 @@ struct A void deallocate(value_type* p, std::size_t n) { - assert(p == (value_type*)0xDEADBEEF); + assert(p == reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF))); assert(n == 10); ++called; } @@ -37,6 +38,6 @@ struct A int main() { A<int> a; - std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10); + std::allocator_traits<A<int> >::deallocate(a, reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF)), 10); assert(called == 1); } |

