Skip to content

Commit

Permalink
include/fmt/format.h: int_writer: correctly cast signed integer to un…
Browse files Browse the repository at this point in the history
…signed to prevent 'implicit conversion changes signedness'-warnings in clang.
  • Loading branch information
martinwuehrer authored and libclapp committed Aug 12, 2020
1 parent fc0d583 commit 3b75c41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,8 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
format_decimal(digits, abs_value, num_digits);
basic_memory_buffer<Char> buffer;
size += prefix_size;
buffer.resize(to_unsigned(size));
const auto usize = to_unsigned(size);
buffer.resize(usize);
basic_string_view<Char> s(&sep, sep_size);
// Index of a decimal digit with the least significant digit having index 0.
int digit_index = 0;
Expand All @@ -1631,7 +1632,7 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
}
if (prefix_size != 0) p[-1] = static_cast<Char>('-');
auto data = buffer.data();
out = write_padded<align::right>(out, specs, size, size, [=](iterator it) {
out = write_padded<align::right>(out, specs, usize, usize, [=](iterator it) {
return copy_str<Char>(data, data + size, it);
});
}
Expand Down

0 comments on commit 3b75c41

Please sign in to comment.