Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! Truncate value of increment operator
Browse files Browse the repository at this point in the history
  • Loading branch information
francois-berder committed Apr 26, 2024
1 parent a951574 commit 62c427e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ 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 = (1ULL << (value_size * 8)) - 1ULL;
MathLib::biguint unsignedMaxValue = -1;
if (value_size < sizeof(MathLib::biguint))
unsignedMaxValue ^= ~(unsignedMaxValue << (value_size * 8));
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 62c427e

Please sign in to comment.