mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Document the boost multiprecision shift bug in RuleList
This commit is contained in:
parent
68e1bf47d5
commit
a7c2dba681
@ -140,6 +140,12 @@ inline bytes toCompactBigEndian(uint8_t _val, unsigned _min = 0)
|
||||
return (_min || _val) ? bytes{ _val } : bytes{};
|
||||
}
|
||||
|
||||
/// Workarounds shift left bug in boost <1.65.1.
|
||||
template <class S> S bigintShiftLeftWorkaround(S const& _a, unsigned _b)
|
||||
{
|
||||
return (S)(bigint(_a) << _b);
|
||||
}
|
||||
|
||||
/// Convenience function for conversion of a u256 to hex
|
||||
inline std::string toHex(u256 val, HexPrefix prefix = HexPrefix::DontAdd)
|
||||
{
|
||||
|
@ -87,12 +87,12 @@ std::vector<SimplificationRule<Pattern>> simplificationRuleListPart1(
|
||||
return B.d();
|
||||
unsigned testBit = unsigned(A.d()) * 8 + 7;
|
||||
u256 mask = (u256(1) << testBit) - 1;
|
||||
return u256(boost::multiprecision::bit_test(B.d(), testBit) ? B.d() | ~mask : B.d() & mask);
|
||||
return boost::multiprecision::bit_test(B.d(), testBit) ? B.d() | ~mask : B.d() & mask;
|
||||
}, false},
|
||||
{{Instruction::SHL, {A, B}}, [=]{
|
||||
if (A.d() > 255)
|
||||
return u256(0);
|
||||
return u256(bigint(B.d()) << unsigned(A.d()));
|
||||
return bigintShiftLeftWorkaround(B.d(), unsigned(A.d()));
|
||||
}, false},
|
||||
{{Instruction::SHR, {A, B}}, [=]{
|
||||
if (A.d() > 255)
|
||||
|
Loading…
Reference in New Issue
Block a user