From 3cd1dac653a2c677af06dcaf7ae78d1298103a53 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 11 Mar 2019 15:33:23 +0100 Subject: [PATCH] :rotating_light: fix MSVC warning #1502 --- include/nlohmann/detail/input/json_sax.hpp | 20 ++++++++++---------- single_include/nlohmann/json.hpp | 20 ++++++++++---------- test/src/unit-allocator.cpp | 3 ++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 6801b3ca2a..4ce5a30de2 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -249,16 +249,16 @@ class json_sax_dom_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 4: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 3: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 5: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP @@ -506,16 +506,16 @@ class json_sax_dom_callback_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 4: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 3: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 5: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 42d65e2210..2e06ef335f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4512,16 +4512,16 @@ class json_sax_dom_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 4: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 3: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 5: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP @@ -4769,16 +4769,16 @@ class json_sax_dom_callback_parser switch ((ex.id / 100) % 100) { case 1: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 4: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); // LCOV_EXCL_START case 2: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 3: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); case 5: - JSON_THROW(*reinterpret_cast(&ex)); + JSON_THROW(*static_cast(&ex)); default: assert(false); // LCOV_EXCL_STOP diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 29ad93f5e6..1c10183d83 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -112,7 +112,8 @@ struct my_allocator : std::allocator } template - struct rebind { + struct rebind + { using other = my_allocator; }; };