File tree Expand file tree Collapse file tree 6 files changed +41
-4
lines changed
src/cdomain/value/cdomains/int
tests/regression/39-signed-overflows Expand file tree Collapse file tree 6 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
102102x-maintenance-intent: ["(latest)" "(latest).(latest-1)"] # also keep previous minor version (with two releases per year, always keep a SV-COMP release)
103103available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
104104pin-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]
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ post-messages: [
148148pin-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"
Original file line number Diff line number Diff line change 33x-maintenance-intent: ["(latest)" "(latest).(latest-1)"] # also keep previous minor version (with two releases per year, always keep a SV-COMP release)
44available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
55pin-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]
Original file line number Diff line number Diff 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)}
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments