From f4fca2d59ab9d02f5b602ef70f9955ec63b3cc6d Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sun, 16 Jun 2019 18:22:40 -0400 Subject: [PATCH 1/3] Fix #1642 While in our case, only the string case was affected, to be safe and allow the library to work with other unforeseen cases, all of the cases have been wrapped with parentheses. Thank you @DyXel and @edo9300 --- include/nlohmann/json.hpp | 12 ++++++------ single_include/nlohmann/json.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index daaf2d66..6aeb33dd 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5746,25 +5746,25 @@ class basic_json return (*lhs.m_value.array) < (*rhs.m_value.array); case value_t::object: - return *lhs.m_value.object < *rhs.m_value.object; + return (*lhs.m_value.object) < (*rhs.m_value.object); case value_t::null: return false; case value_t::string: - return *lhs.m_value.string < *rhs.m_value.string; + return (*lhs.m_value.string) < (*rhs.m_value.string); case value_t::boolean: - return lhs.m_value.boolean < rhs.m_value.boolean; + return (lhs.m_value.boolean) < (rhs.m_value.boolean); case value_t::number_integer: - return lhs.m_value.number_integer < rhs.m_value.number_integer; + return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); case value_t::number_unsigned: - return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned; + return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); case value_t::number_float: - return lhs.m_value.number_float < rhs.m_value.number_float; + return (lhs.m_value.number_float) < (rhs.m_value.number_float); default: return false; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 08ac166b..d06cde78 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -18547,25 +18547,25 @@ class basic_json return (*lhs.m_value.array) < (*rhs.m_value.array); case value_t::object: - return *lhs.m_value.object < *rhs.m_value.object; + return (*lhs.m_value.object) < (*rhs.m_value.object); case value_t::null: return false; case value_t::string: - return *lhs.m_value.string < *rhs.m_value.string; + return (*lhs.m_value.string) < (*rhs.m_value.string); case value_t::boolean: - return lhs.m_value.boolean < rhs.m_value.boolean; + return (lhs.m_value.boolean) < (rhs.m_value.boolean); case value_t::number_integer: - return lhs.m_value.number_integer < rhs.m_value.number_integer; + return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); case value_t::number_unsigned: - return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned; + return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); case value_t::number_float: - return lhs.m_value.number_float < rhs.m_value.number_float; + return (lhs.m_value.number_float) < (rhs.m_value.number_float); default: return false; From 855156b5e87e246acbe607ef68a94412dbf4d01e Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sat, 29 Jun 2019 19:26:38 -0400 Subject: [PATCH 2/3] Add regression tests for #1642 --- test/src/unit-regression.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6b7d90aa..b4850d6b 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1799,3 +1799,14 @@ TEST_CASE("regression tests, exceptions dependent") } } #endif + +///////////////////////////////////////////////////////////////////// +// for #1642 +///////////////////////////////////////////////////////////////////// +template class array {}; +template class object {}; +template class string {}; +template class boolean {}; +template class number_integer {}; +template class number_unsigned {}; +template class number_float {}; \ No newline at end of file From e616d095ab24a924d5e01200f57cc074dc477ca8 Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sun, 30 Jun 2019 11:57:57 -0400 Subject: [PATCH 3/3] Remove boolean regression test for #1642 --- test/src/unit-regression.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index b4850d6b..3dfcef0b 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1806,7 +1806,6 @@ TEST_CASE("regression tests, exceptions dependent") template class array {}; template class object {}; template class string {}; -template class boolean {}; template class number_integer {}; template class number_unsigned {}; template class number_float {}; \ No newline at end of file