From 0f2f01c43a691168fc8e7eab8675d9ef9747c2ba Mon Sep 17 00:00:00 2001 From: Doyle Date: Wed, 11 Dec 2019 16:17:28 +1100 Subject: [PATCH] Fix GCC5.5 not being smart about evaluating dead branches src/quorumnet/bt_serialize.h: In instantiation of 'void quorumnet::detail::bt_deserialize::value, void>::type>::operator()(std::istream&, T&) [with T = long unsigned int; typename std::enable_if::value, void>::type = void; std::istream = std::basic_istream]': src/quorumnet/bt_serialize.cpp:107:17: required from here src/quorumnet/bt_serialize.h:161:75: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op] if (sizeof(T) < sizeof(int64_t) && (read.first.i64 < smin || read.first.i64 > smax)) --- src/quorumnet/bt_serialize.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/quorumnet/bt_serialize.h b/src/quorumnet/bt_serialize.h index 75ca71714..0dcba5444 100644 --- a/src/quorumnet/bt_serialize.h +++ b/src/quorumnet/bt_serialize.h @@ -158,7 +158,9 @@ struct bt_deserialize::value>> { throw bt_deserialize_invalid("Found too-large value " + std::to_string(read.first.u64) + " when deserializing just before input location " + std::to_string(is.tellg())); val = static_cast(read.first.u64); } else { - if (sizeof(T) < sizeof(int64_t) && (read.first.i64 < smin || read.first.i64 > smax)) + bool oob = read.first.i64 < smin; + oob |= read.first.i64 > smax; + if (sizeof(T) < sizeof(int64_t) && oob) throw bt_deserialize_invalid("Found out-of-range value " + std::to_string(read.first.i64) + " when deserializing just before input location " + std::to_string(is.tellg())); val = static_cast(read.first.i64); }