diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index ca6c48ef8..7ef2416a8 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -508,11 +508,12 @@ static ExprEngine::ValuePtr truncateValue(ExprEngine::ValuePtr val, const ValueT return val; if (auto range = std::dynamic_pointer_cast(val)) { - if (range->minValue == range->maxValue) { int128_t newValue = range->minValue; newValue = newValue & (((int128_t)1 << bits) - 1); - // TODO: Sign extension + // Sign extension + if (valueType->sign == ValueType::Sign::SIGNED && newValue & (1ULL << (bits - 1))) + newValue |= ~(((int128_t)1 << bits) - 1); if (newValue == range->minValue) return val; return std::make_shared(ExprEngine::str(newValue), newValue, newValue);