Skip to content

Commit

Permalink
Fix simple -Wsign-conversion cases. (fmtlib#1571)
Browse files Browse the repository at this point in the history
* Fix -Wsign-conversion in bigint::subtract_aligned.

n is assigned a size_t, and only used for comparisons with j.

j is assigned 0, compared to n (size_t), and passed to basic_memory_buffer::operator[] (size_t).

* Fix -Wsign-conversion in bigint::assign.

num_bigits is initialised to 0, is only ever incremented, and is passed to basic_memory_buffer::operator[] (size_t) and basic_memory_buffer::resize (size_t).
  • Loading branch information
refnum authored and Thomas Bernard committed Mar 18, 2020
1 parent 13e8af4 commit 30ec640
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class bigint {
FMT_ASSERT(compare(*this, other) >= 0, "");
bigit borrow = 0;
int i = other.exp_ - exp_;
for (int j = 0, n = static_cast<int>(other.bigits_.size()); j != n;
for (size_t j = 0, n = other.bigits_.size(); j != n;
++i, ++j) {
subtract_bigits(i, other.bigits_[j], borrow);
}
Expand Down Expand Up @@ -579,7 +579,7 @@ class bigint {
}

void assign(uint64_t n) {
int num_bigits = 0;
size_t num_bigits = 0;
do {
bigits_[num_bigits++] = n & ~bigit(0);
n >>= bigit_bits;
Expand Down

0 comments on commit 30ec640

Please sign in to comment.