🚨 fixed some warnings

This commit is contained in:
Niels Lohmann 2019-03-13 22:14:53 +01:00
parent d39842e68f
commit 546e2cbf5e
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
4 changed files with 4 additions and 3 deletions

View file

@ -136,6 +136,7 @@ pedantic_clang:
-Wno-float-equal \ -Wno-float-equal \
-Wno-switch-enum -Wno-covered-switch-default \ -Wno-switch-enum -Wno-covered-switch-default \
-Wno-c++2a-compat \ -Wno-c++2a-compat \
-Wno-c++17-extensions \
-Wno-padded" -Wno-padded"
# calling GCC with most warnings # calling GCC with most warnings

View file

@ -620,7 +620,7 @@ class serializer
if (is_negative) if (is_negative)
{ {
*buffer_ptr = '-'; *buffer_ptr = '-';
abs_value = static_cast<number_unsigned_t>(-1 - x) + 1; abs_value = static_cast<number_unsigned_t>(std::abs(static_cast<std::intmax_t>(x)));
// account one more byte for the minus sign // account one more byte for the minus sign
n_chars = 1 + count_digits(abs_value); n_chars = 1 + count_digits(abs_value);

View file

@ -11533,7 +11533,7 @@ class serializer
if (is_negative) if (is_negative)
{ {
*buffer_ptr = '-'; *buffer_ptr = '-';
abs_value = static_cast<number_unsigned_t>(-1 - x) + 1; abs_value = static_cast<number_unsigned_t>(std::abs(static_cast<std::intmax_t>(x)));
// account one more byte for the minus sign // account one more byte for the minus sign
n_chars = 1 + count_digits(abs_value); n_chars = 1 + count_digits(abs_value);

View file

@ -1762,7 +1762,7 @@ TEST_CASE("regression tests")
-54, -28, -26 -54, -28, -26
}; };
std::string s; std::string s;
for (int i = 0; i < sizeof(data) / sizeof(int); i++) for (unsigned i = 0; i < sizeof(data) / sizeof(int); i++)
{ {
s += static_cast<char>(data[i]); s += static_cast<char>(data[i]);
} }