Skip to content

Commit 133b6e5

Browse files
committed
Add cram test 39-signed-overflows/15-div-minus-1
1 parent eccfc0e commit 133b6e5

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

tests/regression/39-signed-overflows/15-div-minus-1.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
#include <limits.h>
33

44
int main() {
5-
int bad = INT_MIN / -1; // WARN
5+
int bad = INT_MIN / -1; // WARN (overflow)
66
int x, y;
7+
bad = x / y; // WARN (div by zero and overflow, distinguished in cram test)
78
if (y != 0) {
8-
bad = x / y; // WARN
9+
bad = x / y; // WARN (overflow)
910
}
1011
return 0;
1112
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
$ goblint --enable warn.deterministic --enable ana.int.interval 15-div-minus-1.c
2+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:5:9-5:26)
3+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:7:5-7:16)
4+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:9:9-9:20)
5+
[Warning][Integer > DivByZero][CWE-369] Second argument of division might be zero (15-div-minus-1.c:7:5-7:16)
6+
[Info][Deadcode] Logical lines of code (LLoC) summary:
7+
live: 6
8+
dead: 0
9+
total lines: 6
10+
11+
$ goblint --enable warn.deterministic --enable ana.int.interval_set 15-div-minus-1.c
12+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:5:9-5:26)
13+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (15-div-minus-1.c:9:9-9:20)
14+
[Warning][Integer > DivByZero][CWE-369] Second argument of division might be zero (15-div-minus-1.c:7:5-7:16)
15+
[Info][Deadcode] Logical lines of code (LLoC) summary:
16+
live: 6
17+
dead: 0
18+
total lines: 6
19+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(cram
2+
(deps (glob_files *.c)))

0 commit comments

Comments
 (0)