From 58d8d9ab9b1f187bfe4ad33353bdc93889519298 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 12 Feb 2016 23:35:17 +0800 Subject: [PATCH 1/2] Try fixing unit test in release configuration --- include/rapidjson/document.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 5c77dbe..2f6bb2a 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -791,8 +791,8 @@ public: // Checks whether a number can be losslessly converted to a double. bool IsLosslessDouble() const { if (!IsNumber()) return false; - if (IsUint64()) return static_cast(static_cast(GetUint64())) == GetUint64(); - if (IsInt64()) return static_cast< int64_t>(static_cast(GetInt64())) == GetInt64(); + if (IsUint64()) return static_cast(static_cast(GetUint64())) == GetUint64(); + if (IsInt64()) return static_cast(static_cast(GetInt64())) == GetInt64(); return true; // double, int, uint are always lossless } From 98ddfacdf1f4fc8281190999c801d8872c08a06e Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 13 Feb 2016 16:53:45 +0800 Subject: [PATCH 2/2] Another try with volatile --- include/rapidjson/document.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 2f6bb2a..b59cc69 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -791,8 +791,16 @@ public: // Checks whether a number can be losslessly converted to a double. bool IsLosslessDouble() const { if (!IsNumber()) return false; - if (IsUint64()) return static_cast(static_cast(GetUint64())) == GetUint64(); - if (IsInt64()) return static_cast(static_cast(GetInt64())) == GetInt64(); + if (IsUint64()) { + uint64_t u = GetUint64(); + volatile double d = static_cast(u); + return static_cast(d) == u; + } + if (IsInt64()) { + int64_t i = GetInt64(); + volatile double d = static_cast(i); + return static_cast< int64_t>(d) == i; + } return true; // double, int, uint are always lossless }