Skip to content

Commit 172beae

Browse files
committed
Merge pull request #426 from chriseth/optfix
Test for optimizer bug caused by not incrementing the sequence counter.
2 parents ee0ba31 + 3b9969b commit 172beae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/libsolidity/SolidityOptimizer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,20 @@ BOOST_AUTO_TEST_CASE(incorrect_storage_access_bug)
390390
compareVersions("f()");
391391
}
392392

393+
BOOST_AUTO_TEST_CASE(sequence_number_for_calls)
394+
{
395+
// This is a test for a bug that was present because we did not increment the sequence
396+
// number for CALLs - CALLs can read and write from memory (and DELEGATECALLs can do the same
397+
// to storage), so the sequence number should be incremented.
398+
char const* sourceCode = R"(
399+
contract test {
400+
function f(string a, string b) returns (bool) { return sha256(a) == sha256(b); }
401+
}
402+
)";
403+
compileBothVersions(sourceCode);
404+
compareVersions("f(string,string)", 0x40, 0x80, 3, "abc", 3, "def");
405+
}
406+
393407
BOOST_AUTO_TEST_CASE(cse_intermediate_swap)
394408
{
395409
eth::KnownState state;

0 commit comments

Comments
 (0)