aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-04-15 22:49:26 +0800
committerchriseth <c@ethdev.com>2016-04-15 22:49:26 +0800
commit82175fbd2bc70495c031f78f6af1e974565174a5 (patch)
tree54319790d057f9d28459ec14709be3630ac5de8c /test/libsolidity/SolidityEndToEndTest.cpp
parent9137506a15c9b134b39d9dabb6c32a9efb51a793 (diff)
downloaddexon-solidity-82175fbd2bc70495c031f78f6af1e974565174a5.tar.gz
dexon-solidity-82175fbd2bc70495c031f78f6af1e974565174a5.tar.zst
dexon-solidity-82175fbd2bc70495c031f78f6af1e974565174a5.zip
Test for bug when deleting dynamic array of structs.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index c872f011..a26570d3 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6591,6 +6591,28 @@ BOOST_AUTO_TEST_CASE(index_access_with_type_conversion)
BOOST_CHECK(callContractFunction("f(uint256)", u256(0x101)).size() == 256 * 32);
}
+BOOST_AUTO_TEST_CASE(delete_on_array_of_structs)
+{
+ // Test for a bug where we did not increment the counter properly while deleting a dynamic array.
+ char const* sourceCode = R"(
+ contract C {
+ struct S { uint x; uint[] y; }
+ S[] data;
+ function f() returns (bool) {
+ data.length = 2;
+ data[0].x = 2**200;
+ data[1].x = 2**200;
+ delete data;
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ // This code interprets x as an array length and thus will go out of gas.
+ // neither of the two should throw due to out-of-bounds access
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}