Merge pull request #973 from Doy-lee/Gcc5.5Fix

Fix GCC 5.5 not being smart about evaluating dead branches
This commit is contained in:
Doyle 2019-12-11 15:21:30 +10:00 committed by GitHub
commit 0e690e5394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,7 +158,9 @@ struct bt_deserialize<T, std::enable_if_t<std::is_integral<T>::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<T>(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<T>(read.first.i64);
}