[libcxx] r277573 - Fix an MSVC x64 compiler warning. Patch from STL at microsoft.com
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 2 22:48:09 PDT 2016
Author: ericwf
Date: Wed Aug 3 00:48:09 2016
New Revision: 277573
URL: http://llvm.org/viewvc/llvm-project?rev=277573&view=rev
Log:
Fix an MSVC x64 compiler warning. Patch from STL at microsoft.com
Modified:
libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
Modified: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp?rev=277573&r1=277572&r2=277573&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp Wed Aug 3 00:48:09 2016
@@ -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)));
}
Modified: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp?rev=277573&r1=277572&r2=277573&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp Wed Aug 3 00:48:09 2016
@@ -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)));
}
Modified: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp?rev=277573&r1=277572&r2=277573&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp Wed Aug 3 00:48:09 2016
@@ -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);
}
More information about the cfe-commits
mailing list