Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! Truncate value of in…
Browse files Browse the repository at this point in the history
…crement operator
  • Loading branch information
francois-berder committed Apr 30, 2024
1 parent 7d7d1ed commit 16785e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<decltype(unsignedMaxValue)>::max() >> ((sizeof(unsignedMaxValue) - value_size) * 8);
const MathLib::biguint unsignedMaxValue = std::numeric_limits<decltype(unsignedMaxValue)>::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))
Expand Down

0 comments on commit 16785e2

Please sign in to comment.