-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Fixes u256 overflow in logical shift optimization rule and adds tests. #6248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15109,11 +15109,21 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined) | |
c := shl(0xd0, shl(0x40, a)) | ||
} | ||
} | ||
function shl_combined_overflow(uint a) public returns (uint c) { | ||
assembly { | ||
c := shl(0x01, shl(not(0x00), a)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a need for these, just supply a large value in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand - it only works for constants. Supply a large value where? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it has two inputs, sorry. |
||
} | ||
} | ||
function shr_combined_large(uint a) public returns (uint c) { | ||
assembly { | ||
c := shr(0xd0, shr(0x40, a)) | ||
} | ||
} | ||
function shr_combined_overflow(uint a) public returns (uint c) { | ||
assembly { | ||
c := shr(0x01, shr(not(0x00), a)) | ||
} | ||
} | ||
function sar_combined_large(uint a) public returns (uint c) { | ||
assembly { | ||
c := sar(0xd0, sar(0x40, a)) | ||
|
@@ -15152,8 +15162,10 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined) | |
BOOST_CHECK(callContractFunction("shl_combined_large(uint256)", u256(0)) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shl_combined_large(uint256)", u256("0xffff")) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shl_combined_large(uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shl_combined_overflow(uint256)", u256(2)) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shr_combined_large(uint256)", u256(0)) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shr_combined_large(uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("shr_combined_overflow(uint256)", u256(2)) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("sar_combined_large(uint256)", u256(0)) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("sar_combined_large(uint256)", u256("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) == encodeArgs(u256(0))); | ||
BOOST_CHECK(callContractFunction("sar_combined_large(uint256)", u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) == encodeArgs(u256("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))); | ||
|
Uh oh!
There was an error while loading. Please reload this page.