Skip to content

Commit 4e3a77a

Browse files
Fix x86 truncation warnings in sized_allocator.h.
sized_allocator.h(40): warning C4244: 'argument': conversion from 'unsigned __int64' to 'const size_t', possible loss of data sized_allocator.h(43): warning C4244: 'argument': conversion from 'unsigned __int64' to 'const size_t', possible loss of data std::allocator takes std::size_t, so we need to static_cast.
1 parent fb40f8c commit 4e3a77a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libcxx/test/support/sized_allocator.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ class sized_allocator {
3737
TEST_CONSTEXPR_CXX20 T* allocate(size_type n) {
3838
if (n > max_size())
3939
TEST_THROW(std::bad_array_new_length());
40-
return std::allocator<T>().allocate(n);
40+
return std::allocator<T>().allocate(static_cast<std::size_t>(n));
4141
}
4242

43-
TEST_CONSTEXPR_CXX20 void deallocate(T* p, size_type n) TEST_NOEXCEPT { std::allocator<T>().deallocate(p, n); }
43+
TEST_CONSTEXPR_CXX20 void deallocate(T* p, size_type n) TEST_NOEXCEPT {
44+
std::allocator<T>().deallocate(p, static_cast<std::size_t>(n));
45+
}
4446

4547
TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT {
4648
return std::numeric_limits<size_type>::max() / sizeof(value_type);

0 commit comments

Comments
 (0)