diff options
author | chriseth <c@ethdev.com> | 2016-07-29 17:46:57 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-08-01 21:30:19 +0800 |
commit | ac0d1388008ed616ab7b35a5b3a27e7400decd46 (patch) | |
tree | a6e2f3d6ebaa20077a7742d40a25954863216612 /test/libsolidity/SolidityOptimizer.cpp | |
parent | 21a7dda733b68a4417c4822b22bd4810a9c3e5d1 (diff) | |
download | dexon-solidity-ac0d1388008ed616ab7b35a5b3a27e7400decd46.tar.gz dexon-solidity-ac0d1388008ed616ab7b35a5b3a27e7400decd46.tar.zst dexon-solidity-ac0d1388008ed616ab7b35a5b3a27e7400decd46.zip |
Test case.
Diffstat (limited to 'test/libsolidity/SolidityOptimizer.cpp')
-rw-r--r-- | test/libsolidity/SolidityOptimizer.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 67b161b9..2e4ed4b3 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -1177,6 +1177,64 @@ BOOST_AUTO_TEST_CASE(computing_constants) ) == optimizedBytecode.cend()); } +BOOST_AUTO_TEST_CASE(inconsistency) +{ + // This is a test of a bug in the optimizer. + char const* sourceCode = R"( + contract Inconsistency { + struct Value { + uint badnum; + uint number; + } + + struct Container { + uint[] valueIndices; + Value[] values; + } + + Container[] containers; + uint[] valueIndices; + uint INDEX_ZERO = 0; + uint debug; + + // Called with params: containerIndex=0, valueIndex=0 + function levelIII(uint containerIndex, uint valueIndex) private { + Container container = containers[containerIndex]; + Value value = container.values[valueIndex]; + debug = container.valueIndices[value.number]; + } + function levelII() private { + for (uint i = 0; i < valueIndices.length; i++) { + levelIII(INDEX_ZERO, valueIndices[i]); + } + } + + function trigger() public returns (uint) { + containers.length++; + Container container = containers[0]; + + container.values.push(Value({ + badnum: 9000, + number: 0 + })); + + container.valueIndices.length++; + valueIndices.length++; + + levelII(); + return debug; + } + + function DoNotCallButDoNotDelete() public { + levelII(); + levelIII(1, 2); + } + } + )"; + compileBothVersions(sourceCode); + compareVersions("trigger()"); +} + BOOST_AUTO_TEST_SUITE_END() } |