Skip to content

Commit

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

Please sign in to comment.