diff --git a/Makefile b/Makefile index 297443a5..f16b209a 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 9994372d..74c2d771 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -620,7 +620,7 @@ class serializer if (is_negative) { *buffer_ptr = '-'; - abs_value = static_cast(-1 - x) + 1; + abs_value = static_cast(std::abs(static_cast(x))); // account one more byte for the minus sign n_chars = 1 + count_digits(abs_value); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ded6c2bc..8f61edc7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -11533,7 +11533,7 @@ class serializer if (is_negative) { *buffer_ptr = '-'; - abs_value = static_cast(-1 - x) + 1; + abs_value = static_cast(std::abs(static_cast(x))); // account one more byte for the minus sign n_chars = 1 + count_digits(abs_value); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 975b9239..822cac96 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -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(data[i]); }