Fix mixed signed/unsigned arithmetic in BitVector.
Change-Id: I59c7f5a26e42689f77b067f4c73b086335e9273d
diff --git a/runtime/base/bit_vector.cc b/runtime/base/bit_vector.cc
index 71dec7a..63e9355 100644
--- a/runtime/base/bit_vector.cc
+++ b/runtime/base/bit_vector.cc
@@ -16,6 +16,7 @@
#include "bit_vector.h"
+#include <limits>
#include <sstream>
#include "allocator.h"
@@ -218,13 +219,13 @@
uint32_t idx;
// We can set every storage element with -1.
for (idx = 0; idx < WordIndex(num_bits); idx++) {
- storage_[idx] = -1;
+ storage_[idx] = std::numeric_limits<uint32_t>::max();
}
// Handle the potentially last few bits.
uint32_t rem_num_bits = num_bits & 0x1f;
if (rem_num_bits != 0) {
- storage_[idx] = (1 << rem_num_bits) - 1;
+ storage_[idx] = (1U << rem_num_bits) - 1;
++idx;
}