Update overflow tests

This commit is contained in:
Leonardo Alt 2020-08-11 13:39:23 +02:00
parent 8a06041bbe
commit 80ab56dbc6
14 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
return x / y;
}
}
// ----
// Warning 1218: (110-115): Error trying to invoke SMT solver.
// Warning 3046: (110-115): Division by zero happens here
// Warning 2661: (110-115): Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
require(x >= y);
return x - y;
}
}
// ----
// Warning 4984: (129-134): Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here

View File

@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
require(x + y >= x);
return x + y;
}
}
// ----
// Warning 3944: (111-116): Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here
// Warning 3944: (133-138): Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
return x % y;
}
}
// ----
// Warning 3046: (110-115): Division by zero happens here

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
return x * y;
}
}
// ----
// Warning 3944: (110-115): Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here
// Warning 4984: (110-115): Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
return x - y;
}
}
// ----
// Warning 3944: (110-115): Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here
// Warning 4984: (110-115): Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f(int x, int y) public pure returns (int) {
return x + y;
}
}
// ----
// Warning 3944: (110-115): Underflow (resulting value less than -57896044618658097711785492504343953926634992332820282019728792003956564819968) happens here
// Warning 4984: (110-115): Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
return x / y;
}
}
// ----
// Warning 3046: (113-118): Division by zero happens here

View File

@ -0,0 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
require(x >= y);
return x - y;
}
}

View File

@ -0,0 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
require(x + y >= x);
return x + y;
}
}

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
return x % y;
}
}
// ----
// Warning 3046: (113-118): Division by zero happens here

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
return x * y;
}
}
// ----
// Warning 4984: (113-118): Overflow (resulting value larger than 2**256 - 1) happens here

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
return x - y;
}
}
// ----
// Warning 3944: (113-118): Underflow (resulting value less than 0) happens here

View File

@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f(uint x, uint y) public pure returns (uint) {
return x + y;
}
}
// ----
// Warning 4984: (113-118): Overflow (resulting value larger than 2**256 - 1) happens here