Skip to content

Commit d3b947c

Browse files
Use uint64_t for (de)allocated_; use unsigned int loop variable
1 parent e0deb1e commit d3b947c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

libcxx/test/std/strings/basic.string/string.capacity/deallocate_size.pass.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#include "test_macros.h"
2020

21-
static std::size_t allocated_;
22-
static std::size_t deallocated_;
21+
static std::uint64_t allocated_;
22+
static std::uint64_t deallocated_;
2323

2424
template <class T, class Sz>
2525
struct test_alloc {
@@ -42,12 +42,12 @@ struct test_alloc {
4242
TEST_CONSTEXPR test_alloc(const test_alloc<U, Sz>&) TEST_NOEXCEPT {}
4343

4444
pointer allocate(size_type n, const void* = nullptr) {
45-
allocated_ += static_cast<std::size_t>(n);
45+
allocated_ += n;
4646
return std::allocator<value_type>().allocate(static_cast<std::size_t>(n));
4747
}
4848

4949
void deallocate(pointer p, size_type s) {
50-
deallocated_ += static_cast<std::size_t>(s);
50+
deallocated_ += s;
5151
std::allocator<value_type>().deallocate(p, static_cast<std::size_t>(s));
5252
}
5353

@@ -66,9 +66,10 @@ struct test_alloc {
6666

6767
template <class Sz>
6868
void test() {
69-
for (int i = 1; i < 1000; ++i) {
69+
for (unsigned int i = 1; i < 1000; ++i) {
7070
{
71-
TEST_MAYBE_UNUSED std::basic_string<char, std::char_traits<char>, test_alloc<char, Sz> > s(i, 't');
71+
std::basic_string<char, std::char_traits<char>, test_alloc<char, Sz> > s(i, 't');
72+
(void)s;
7273
}
7374
assert(allocated_ == deallocated_);
7475
}

0 commit comments

Comments
 (0)