From 9073b2ca392893b84bbee789ccb171dda7bef022 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 30 Apr 2016 16:22:27 +0200 Subject: [PATCH] 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 65ced730..80b67710 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 0aa8321e..1c80915b 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