mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9723 from ethereum/smt_fix_rational
[SMTChecker] Fix rational number short circuit
This commit is contained in:
commit
3599258d86
@ -452,11 +452,14 @@ void SMTEncoder::endVisit(TupleExpression const& _tuple)
|
|||||||
|
|
||||||
void SMTEncoder::endVisit(UnaryOperation const& _op)
|
void SMTEncoder::endVisit(UnaryOperation const& _op)
|
||||||
{
|
{
|
||||||
if (TokenTraits::isBitOp(_op.getOperator()))
|
/// We need to shortcut here due to potentially unknown
|
||||||
return bitwiseNotOperation(_op);
|
/// rational number sizes.
|
||||||
if (_op.annotation().type->category() == Type::Category::RationalNumber)
|
if (_op.annotation().type->category() == Type::Category::RationalNumber)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (TokenTraits::isBitOp(_op.getOperator()))
|
||||||
|
return bitwiseNotOperation(_op);
|
||||||
|
|
||||||
createExpr(_op);
|
createExpr(_op);
|
||||||
|
|
||||||
auto const* subExpr = innermostTuple(_op.subExpression());
|
auto const* subExpr = innermostTuple(_op.subExpression());
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
uint x = uint(~1);
|
||||||
|
// This assertion fails because type conversion is still unsupported.
|
||||||
|
assert(x == 2**256 - 2);
|
||||||
|
assert(~1 == -2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 6328: (169-192): Assertion violation happens here
|
@ -0,0 +1,15 @@
|
|||||||
|
pragma experimental SMTChecker;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public pure {
|
||||||
|
assert(~1 | (~0xff & 0) == -2);
|
||||||
|
int x = ~1 | (~0xff ^ 0);
|
||||||
|
/// Result is negative, assertion fails.
|
||||||
|
assert(x > 0);
|
||||||
|
int y = ~x | (0xff & 1);
|
||||||
|
assert(y > 0);
|
||||||
|
assert(y & (0xffffffffffffffffff & 1) == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 6328: (181-194): Assertion violation happens here
|
Loading…
Reference in New Issue
Block a user