aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-03-31 07:17:48 +0800
committerchriseth <c@ethdev.com>2016-03-31 07:25:45 +0800
commit98b686c67207c2c3ced0110dced5ed6934716386 (patch)
treee305f602121710fbe348cdc8e390d84fd455485e
parent2acdfc527e4be019ecacf2487f479cca9585bea1 (diff)
downloaddexon-solidity-98b686c67207c2c3ced0110dced5ed6934716386.tar.gz
dexon-solidity-98b686c67207c2c3ced0110dced5ed6934716386.tar.zst
dexon-solidity-98b686c67207c2c3ced0110dced5ed6934716386.zip
Test to check we correctly clean higher order bits for index access.
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 663493c9..c872f011 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6575,6 +6575,22 @@ BOOST_AUTO_TEST_CASE(inline_assembly_jumps)
BOOST_CHECK(callContractFunction("f()", u256(7)) == encodeArgs(u256(34)));
}
+BOOST_AUTO_TEST_CASE(index_access_with_type_conversion)
+{
+ // Test for a bug where higher order bits cleanup was not done for array index access.
+ char const* sourceCode = R"(
+ contract C {
+ function f(uint x) returns (uint[256] r){
+ r[uint8(x)] = 2;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ // neither of the two should throw due to out-of-bounds access
+ BOOST_CHECK(callContractFunction("f(uint256)", u256(0x01)).size() == 256 * 32);
+ BOOST_CHECK(callContractFunction("f(uint256)", u256(0x101)).size() == 256 * 32);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}