Skip to content

Commit dac19d3

Browse files
committed
Merge remote-tracking branch 'origin/overflow-mod' into dash-dev
2 parents c43d10f + 3e459d0 commit dac19d3

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

goblint.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
102102
x-maintenance-intent: ["(latest)" "(latest).(latest-1)"] # also keep previous minor version (with two releases per year, always keep a SV-COMP release)
103103
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
104104
pin-depends: [
105-
[ "goblint-cil.2.0.9" "git+https://github.com/goblint/cil.git#2edc807cfc8ce80e74e932a8d84a809a44ec0c3d" ]
105+
[ "goblint-cil.2.0.9" "git+https://github.com/goblint/cil.git#d4ff56f4994f8acbe1544f15a103748942645961" ]
106106
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release
107107
[ "apron.v0.9.15" "git+https://github.com/antoinemine/apron.git#418a217c7a70dae3f422678f3aaba38ae374d91a" ]
108108
]

goblint.opam.locked

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ post-messages: [
148148
pin-depends: [
149149
[
150150
"goblint-cil.2.0.9"
151-
"git+https://github.com/goblint/cil.git#2edc807cfc8ce80e74e932a8d84a809a44ec0c3d"
151+
"git+https://github.com/goblint/cil.git#d4ff56f4994f8acbe1544f15a103748942645961"
152152
]
153153
[
154154
"apron.v0.9.15"

goblint.opam.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
x-maintenance-intent: ["(latest)" "(latest).(latest-1)"] # also keep previous minor version (with two releases per year, always keep a SV-COMP release)
44
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
55
pin-depends: [
6-
[ "goblint-cil.2.0.9" "git+https://github.com/goblint/cil.git#2edc807cfc8ce80e74e932a8d84a809a44ec0c3d" ]
6+
[ "goblint-cil.2.0.9" "git+https://github.com/goblint/cil.git#d4ff56f4994f8acbe1544f15a103748942645961" ]
77
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release
88
[ "apron.v0.9.15" "git+https://github.com/antoinemine/apron.git#418a217c7a70dae3f422678f3aaba38ae374d91a" ]
99
]

src/cdomain/value/cdomains/int/intDomTuple.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,12 @@ module IntDomTupleImpl = struct
448448
{f2_ovc = (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.div ?no_ov ik)}
449449

450450
let rem ik =
451-
map2 ik {f2= (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.rem ik)}
451+
map2ovc ~op:(Binop Mod) ik
452+
{f2_ovc = (fun (type a) (module I : SOverflow with type t = a) ?no_ov x y ->
453+
(* C11 6.5.5.6: if [x/y] is not representable (i.e. overflows), then [x%y] is undefined (let's also call it overflow) *)
454+
let (_, div_ov) = I.div ?no_ov ik x y in
455+
(I.rem ik x y, div_ov) (* TODO: should [div] overflow check be moved into each [rem] in each int domain? *)
456+
)}
452457

453458
let lt ik =
454459
map2 ik {f2= (fun (type a) (module I : SOverflow with type t = a) ?no_ov -> I.lt ik)}
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; // 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; // WARN (overflow)
10+
}
11+
return 0;
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
$ goblint --enable warn.deterministic --enable ana.int.interval 17-mod-minus-1.c
2+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:5:9-5:26)
3+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:7:5-7:16)
4+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:9:9-9:20)
5+
[Warning][Integer > DivByZero][CWE-369] Second argument of modulo might be zero (17-mod-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 17-mod-minus-1.c
12+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:5:9-5:26)
13+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:7:5-7:16)
14+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow in % (17-mod-minus-1.c:9:9-9:20)
15+
[Warning][Integer > DivByZero][CWE-369] Second argument of modulo might be zero (17-mod-minus-1.c:7:5-7:16)
16+
[Info][Deadcode] Logical lines of code (LLoC) summary:
17+
live: 6
18+
dead: 0
19+
total lines: 6
20+

0 commit comments

Comments
 (0)