Merge pull request #6351 from ethereum/smt_shortcircuit_test

[SMTChecker] Add buggy short circuit test
This commit is contained in:
Alex Beregszaszi 2019-03-21 21:24:51 +00:00 committed by GitHub
commit cbbc2df506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract c {
uint x;
function f() internal returns (uint) {
x = x + 1;
return x;
}
function g() public {
x = 0;
assert((f() > 0) || (f() > 0));
// This assertion should NOT fail.
// It currently does because the SMTChecker does not
// handle short-circuiting properly and inlines f() twice.
assert(x == 1);
}
}
// ----
// Warning: (101-106): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (344-358): Assertion violation happens here