diff --git a/libcxx/test/std/strings/basic.string/string.capacity/deallocate_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/deallocate_size.pass.cpp index 00f9e2b846783..ecdc39701641d 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/deallocate_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/deallocate_size.pass.cpp @@ -12,12 +12,14 @@ #include #include +#include #include #include #include "test_macros.h" -static int allocated_; +static std::uint64_t allocated_; +static std::uint64_t deallocated_; template struct test_alloc { @@ -41,12 +43,12 @@ struct test_alloc { pointer allocate(size_type n, const void* = nullptr) { allocated_ += n; - return std::allocator().allocate(n); + return std::allocator().allocate(static_cast(n)); } void deallocate(pointer p, size_type s) { - allocated_ -= s; - std::allocator().deallocate(p, s); + deallocated_ += s; + std::allocator().deallocate(p, static_cast(s)); } template @@ -64,14 +66,13 @@ struct test_alloc { template void test() { - for (int i = 1; i < 1000; ++i) { - using Str = std::basic_string, test_alloc >; + for (unsigned int i = 1; i < 1000; ++i) { { - Str s(i, 't'); - assert(allocated_ == 0 || allocated_ >= i); + std::basic_string, test_alloc > s(i, 't'); + (void)s; } + assert(allocated_ == deallocated_); } - assert(allocated_ == 0); } int main(int, char**) {