diff --git a/src/json.hpp b/src/json.hpp index 876c35b6bf6f2d7c490dd0da550322d07529646a..bd172559e517b568d7691dc352ed2858e3f8a2a0 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6419,9 +6419,8 @@ class basic_json private: static constexpr size_t s_capacity = 30; - std::array m_buf{}; // +2 for leading '-' - // and trailing '\0' - + std::array m_buf{{}}; // +2 for leading '-' + // and trailing '\0' template void x_write(T x, std::true_type) { @@ -6432,7 +6431,8 @@ class basic_json while(x and i < s_capacity) { - m_buf[i++] = static_cast('0' + std::labs(x % 10)); + const auto digit = std::labs(static_cast(x % 10)); + m_buf[i++] = static_cast('0' + digit); x /= 10; } diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 55574beea4599410c05df5de7440f7aaf5300f62..4411c64a9331047fb6a9fdf40759780e1a4152ba 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6419,9 +6419,8 @@ class basic_json private: static constexpr size_t s_capacity = 30; - std::array m_buf{}; // +2 for leading '-' - // and trailing '\0' - + std::array m_buf{{}}; // +2 for leading '-' + // and trailing '\0' template void x_write(T x, std::true_type) { @@ -6432,7 +6431,8 @@ class basic_json while(x and i < s_capacity) { - m_buf[i++] = static_cast('0' + std::labs(x % 10)); + const auto digit = std::labs(static_cast(x % 10)); + m_buf[i++] = static_cast('0' + digit); x /= 10; }