Skip to content

Commit 39e8b48

Browse files
committed
Add signed int overflow behaviour tests for the new SMT backend.
1 parent fe754e0 commit 39e8b48

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <limits.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int a = INT_MAX;
7+
int b = INT_MIN;
8+
9+
__CPROVER_assert(
10+
a + 1 == INT_MIN, "Wrap-around to INT_MIN when adding to INT_MAX");
11+
__CPROVER_assert(
12+
b - 1 == INT_MAX, "Wrap-around to INT_MAX when subtracting from INT_MIN");
13+
__CPROVER_assert(a - b == -1, "INT_MAX minus INT_MIN equals -1");
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
overflow_behaviour.c
3+
--incremental-smt2-solver 'z3 --smt2 -in' --trace
4+
\[main\.assertion\.1\] line \d+ Wrap-around to INT_MIN when adding to INT_MAX: SUCCESS
5+
\[main\.assertion\.2\] line \d+ Wrap-around to INT_MAX when subtracting from INT_MIN: SUCCESS
6+
\[main\.assertion\.3\] line \d+ INT_MAX minus INT_MIN equals -1: SUCCESS
7+
^VERIFICATION SUCCESSFUL$
8+
^EXIT=0$
9+
^SIGNAL=0$
10+
--
11+
--
12+
This test is designed to test wrap-around behaviour for boundary-values
13+
of the int domain.

0 commit comments

Comments
 (0)