diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index a12560fa14b8..5c593973b854 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -606,7 +606,7 @@ static ValueFlow::Value truncateImplicitConversion(Token* parent, const ValueFlo static long long truncateIntValue(long long value, size_t value_size, const ValueType::Sign dst_sign) { - const MathLib::biguint unsignedMaxValue = std::numeric_limits::max() >> ((sizeof(unsignedMaxValue) - value_size) * 8); + const MathLib::biguint unsignedMaxValue = std::numeric_limits::max() >> (sizeof(unsignedMaxValue) != value_size ? ((sizeof(unsignedMaxValue) - value_size) * 8) : 0); const MathLib::biguint signBit = 1ULL << (value_size * 8 - 1); value &= unsignedMaxValue; if (dst_sign == ValueType::Sign::SIGNED && (value & signBit))