From 62f81a60d7a9d62ee2fcf2569b8f4a7aceea5551 Mon Sep 17 00:00:00 2001 From: Niels Date: Fri, 29 Apr 2016 21:23:13 +0200 Subject: [PATCH 1/3] hopefully fixed a warning --- src/json.hpp | 6 ++++-- src/json.hpp.re2c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 57a8f4c72d..65ced7305f 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -6078,9 +6078,11 @@ class basic_json { // convert a number 0..15 to its hex representation // (0..f) - auto hexify = [](const char v) -> char + const auto hexify = [](const int v) -> char { - return (v < 10) ? ('0' + v) : ('a' + v - 10); + return (v < 10) + ? ('0' + static_cast(v)) + : ('a' + static_cast(v - 10)); }; // print character c as \uxxxx diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index cdd96ee918..0aa8321e56 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -6078,9 +6078,11 @@ class basic_json { // convert a number 0..15 to its hex representation // (0..f) - auto hexify = [](const char v) -> char + const auto hexify = [](const int v) -> char { - return (v < 10) ? ('0' + v) : ('a' + v - 10); + return (v < 10) + ? ('0' + static_cast(v)) + : ('a' + static_cast(v - 10)); }; // print character c as \uxxxx From 9073b2ca392893b84bbee789ccb171dda7bef022 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 30 Apr 2016 16:22:27 +0200 Subject: [PATCH 2/3] hopefully removed some warnings --- src/json.hpp | 6 +++--- src/json.hpp.re2c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 65ced7305f..80b67710a6 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -757,7 +757,7 @@ class basic_json /// assignment type_data_t& operator=(value_t rhs) { - bits.type = static_cast(rhs); + bits.type = static_cast(rhs) & 15; // avoid overflow return *this; } @@ -765,7 +765,7 @@ class basic_json type_data_t(value_t t) noexcept { *reinterpret_cast(this) = 0; - bits.type = static_cast(t); + bits.type = static_cast(t) & 15; // avoid overflow } /// default constructor @@ -6082,7 +6082,7 @@ class basic_json { return (v < 10) ? ('0' + static_cast(v)) - : ('a' + static_cast(v - 10)); + : ('a' + static_cast((v - 10) & 0xff)); }; // print character c as \uxxxx diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 0aa8321e56..1c80915b0e 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -757,7 +757,7 @@ class basic_json /// assignment type_data_t& operator=(value_t rhs) { - bits.type = static_cast(rhs); + bits.type = static_cast(rhs) & 15; // avoid overflow return *this; } @@ -765,7 +765,7 @@ class basic_json type_data_t(value_t t) noexcept { *reinterpret_cast(this) = 0; - bits.type = static_cast(t); + bits.type = static_cast(t) & 15; // avoid overflow } /// default constructor @@ -6082,7 +6082,7 @@ class basic_json { return (v < 10) ? ('0' + static_cast(v)) - : ('a' + static_cast(v - 10)); + : ('a' + static_cast((v - 10) & 0xff)); }; // print character c as \uxxxx From 6d8e00ade80b72ffbb849c363cb4bd0f37d0804d Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 8 May 2016 17:17:17 +0200 Subject: [PATCH 3/3] another try to remove a warning --- src/json.hpp | 2 +- src/json.hpp.re2c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 459f7f3dfe..bc6fd70987 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -5967,7 +5967,7 @@ class basic_json { return (v < 10) ? ('0' + static_cast(v)) - : ('a' + static_cast((v - 10) & 0xff)); + : ('a' + static_cast((v - 10) & 0x1f)); }; // print character c as \uxxxx diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 685024a5f2..793cc73802 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -5967,7 +5967,7 @@ class basic_json { return (v < 10) ? ('0' + static_cast(v)) - : ('a' + static_cast((v - 10) & 0xff)); + : ('a' + static_cast((v - 10) & 0x1f)); }; // print character c as \uxxxx