aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityOptimizer.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-01-15 23:23:49 +0800
committerchriseth <c@ethdev.com>2016-01-16 00:02:37 +0800
commita88835bbce89da14e89591c58c2a74bdaedb2c19 (patch)
tree2e851848ed83048196c4472f941c605f147fc601 /test/libsolidity/SolidityOptimizer.cpp
parentd2f18c73f75ad5983550fe8a985824d0fda0b640 (diff)
downloaddexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.gz
dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.tar.zst
dexon-solidity-a88835bbce89da14e89591c58c2a74bdaedb2c19.zip
Test for incorrect storage access.
Diffstat (limited to 'test/libsolidity/SolidityOptimizer.cpp')
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index 732f599f..2f1eb04e 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -369,6 +369,27 @@ BOOST_AUTO_TEST_CASE(successor_not_found_bug)
compileBothVersions(sourceCode);
}
+BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
+{
+ // This bug appeared because a sha3 operation with too low sequence number was used,
+ // resulting in memory not being rewritten before the sha3. The fix was to
+ // take the max of the min sequence numbers when merging the states.
+ char const* sourceCode = R"(
+ contract C
+ {
+ mapping(uint => uint) data;
+ function f() returns (uint)
+ {
+ if(data[now] == 0)
+ data[uint(-7)] = 5;
+ return data[now];
+ }
+ }
+ )";
+ compileBothVersions(sourceCode);
+ compareVersions("f()");
+}
+
BOOST_AUTO_TEST_CASE(cse_intermediate_swap)
{
eth::KnownState state;