diff --git a/src/json.hpp b/src/json.hpp index 04ea79a2..67c6b6fc 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6621,7 +6621,7 @@ class basic_json // four-byte uint32_t add_to_vector(v, 4, j.m_value.number_integer); } - else if (j.m_value.number_integer <= UINT64_MAX) + else { v.push_back(0x1b); // eight-byte uint64_t @@ -6655,7 +6655,7 @@ class basic_json v.push_back(0x3a); add_to_vector(v, 4, positive_number); } - else if (positive_number <= UINT64_MAX) + else { // int 64 v.push_back(0x3b); @@ -7186,7 +7186,7 @@ class basic_json case 0x3b: // Negative integer -1-n (eight-byte uint64_t follows) { idx += 8; // skip 8 content bytes - return static_cast(-1) - get_from_vector(v, current_idx); + return static_cast(-1) - static_cast(get_from_vector(v, current_idx)); } // UTF-8 string (0x00..0x17 bytes follow) diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 76084140..2ad5e7ce 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6621,7 +6621,7 @@ class basic_json // four-byte uint32_t add_to_vector(v, 4, j.m_value.number_integer); } - else if (j.m_value.number_integer <= UINT64_MAX) + else { v.push_back(0x1b); // eight-byte uint64_t @@ -6655,7 +6655,7 @@ class basic_json v.push_back(0x3a); add_to_vector(v, 4, positive_number); } - else if (positive_number <= UINT64_MAX) + else { // int 64 v.push_back(0x3b); @@ -7186,7 +7186,7 @@ class basic_json case 0x3b: // Negative integer -1-n (eight-byte uint64_t follows) { idx += 8; // skip 8 content bytes - return static_cast(-1) - get_from_vector(v, current_idx); + return static_cast(-1) - static_cast(get_from_vector(v, current_idx)); } // UTF-8 string (0x00..0x17 bytes follow) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index aaad8c14..604d7437 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -138,7 +138,7 @@ TEST_CASE("CBOR") (static_cast(result[7]) << 010) + static_cast(result[8])); CHECK(restored == positive); - CHECK(-1 - restored == i); + CHECK(-1 - static_cast(restored) == i); // roundtrip CHECK(json::from_cbor(result) == j);