[SMTChecker] Fix SMT logic error when doing compound assignment with string literlas.

This commit is contained in:
Djordje Mijovic
2020-11-24 19:14:15 +01:00
parent 2d235bf7b0
commit 26c43cfc66
5 changed files with 67 additions and 4 deletions
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes memory y = "def";
y[0] &= "d";
assert(y[0] == "d");
y[0] |= "e";
assert(y[0] == "d"); // fails
y[0] ^= "f";
assert(y[0] == (byte("d") | byte("e")) ^ byte("f"));
}
}
// ----
// Warning 6328: (189-208): CHC: Assertion violation happens here.
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes3 y = "def";
y &= "def";
assert(y == "def");
y |= "dee";
assert(y == "def"); // fails
y ^= "fed";
assert(y == (bytes3("def") | bytes3("dee")) ^ bytes3("fed"));
}
}
// ----
// Warning 6328: (180-198): CHC: Assertion violation happens here.
@@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
bytes32 y = "abcdefghabcdefghabcdefghabcdefgh";
bytes32 z = y;
y &= "bcdefghabcdefghabcdefghabcdefgha";
z &= "bcdefghabcdefghabcdefghabcdefgha";
assert(y == "abcdefghabcdefghabcdefghabcdefgh"); // fails
y |= "cdefghabcdefghabcdefghabcdefghab";
z |= "cdefghabcdefghabcdefghabcdefghab";
assert(y == "abcdefghabcdefghabcdefghabcd"); // fails
y ^= "abcdefghabcdefghabcdefghabcdefgh";
assert(y == z ^ "abcdefghabcdefghabcdefghabcdefgh");
}
}
// ----
// Warning 6328: (262-309): CHC: Assertion violation happens here.
// Warning 6328: (427-470): CHC: Assertion violation happens here.