Skip to content

Commit 6ad40ab

Browse files
committed
Add test 39-signed-overflows/17-mod-minus-1
1 parent 3127a30 commit 6ad40ab

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// PARAM: --enable ana.int.interval
2+
#include <limits.h>
3+
4+
int main() {
5+
int bad = INT_MIN % -1; // TODO WARN (overflow)
6+
int x, y;
7+
bad = x % y; // WARN (div by zero and overflow, distinguished in cram test)
8+
if (y != 0) {
9+
bad = x % y; // TODO WARN (overflow)
10+
}
11+
return 0;
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
TODO: should warn about overflow in all three %-s
2+
$ goblint --enable warn.deterministic --enable ana.int.interval 17-mod-minus-1.c
3+
[Warning][Integer > DivByZero][CWE-369] Second argument of modulo might be zero (17-mod-minus-1.c:7:5-7:16)
4+
[Info][Deadcode] Logical lines of code (LLoC) summary:
5+
live: 6
6+
dead: 0
7+
total lines: 6
8+
9+
TODO: should warn about overflow in all three %-s
10+
$ goblint --enable warn.deterministic --enable ana.int.interval_set 17-mod-minus-1.c
11+
[Warning][Integer > DivByZero][CWE-369] Second argument of modulo might be zero (17-mod-minus-1.c:7:5-7:16)
12+
[Info][Deadcode] Logical lines of code (LLoC) summary:
13+
live: 6
14+
dead: 0
15+
total lines: 6
16+

0 commit comments

Comments
 (0)