Skip to content

Commit

Permalink
🚨 fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Mar 13, 2019
1 parent d39842e commit 546e2cb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pedantic_clang:
-Wno-float-equal \
-Wno-switch-enum -Wno-covered-switch-default \
-Wno-c++2a-compat \
-Wno-c++17-extensions \
-Wno-padded"

# calling GCC with most warnings
Expand Down
2 changes: 1 addition & 1 deletion include/nlohmann/detail/output/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class serializer
if (is_negative)
{
*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
n_chars = 1 + count_digits(abs_value);
Expand Down
2 changes: 1 addition & 1 deletion single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11533,7 +11533,7 @@ class serializer
if (is_negative)
{
*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
n_chars = 1 + count_digits(abs_value);
Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ TEST_CASE("regression tests")
-54, -28, -26
};
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]);
}
Expand Down

0 comments on commit 546e2cb

Please sign in to comment.