diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 37c2e4863f14..7e7cf5b9a813 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))