From e6159ed1a931c888b2eac57af4b1c7a2824f4c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20W=C3=BChrer?= Date: Wed, 12 Aug 2020 18:09:45 +0200 Subject: [PATCH] include/fmt/format.h: int_writer: correctly cast signed integer to unsigned to prevent 'implicit conversion changes signedness'-warnings in clang. --- include/fmt/format.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 8a961122..dc88a984 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1610,7 +1610,8 @@ template struct int_writer { format_decimal(digits, abs_value, num_digits); basic_memory_buffer buffer; size += prefix_size; - buffer.resize(to_unsigned(size)); + const auto usize = to_unsigned(size); + buffer.resize(usize); basic_string_view s(&sep, sep_size); // Index of a decimal digit with the least significant digit having index 0. int digit_index = 0; @@ -1631,7 +1632,7 @@ template struct int_writer { } if (prefix_size != 0) p[-1] = static_cast('-'); auto data = buffer.data(); - out = write_padded(out, specs, size, size, [=](iterator it) { + out = write_padded(out, specs, usize, usize, [=](iterator it) { return copy_str(data, data + size, it); }); }