Skip to content

Commit 53858f2

Browse files
Merge pull request #1186 from goblint/issue_1005
No shortcut for `narrow` and `meet` in HConsed when int refinement is active
2 parents 2125370 + eeb1df0 commit 53858f2

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/common/domains/lattice.ml

+7-2
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,15 @@ end
151151
module HConsed (Base:S) =
152152
struct
153153
include Printable.HConsed (Base)
154+
155+
(* We do refine int values on narrow and meet {!IntDomain.IntDomTupleImpl}, which can lead to fixpoint issues if we assume x op x = x *)
156+
(* see https://github.com/goblint/analyzer/issues/1005 *)
157+
let int_refine_active = GobConfig.get_string "ana.int.refinement" <> "never"
158+
154159
let lift_f2 f x y = f (unlift x) (unlift y)
155-
let narrow x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.narrow x y)
160+
let narrow x y = if (not int_refine_active) && x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.narrow x y)
156161
let widen x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.widen x y)
157-
let meet x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.meet x y)
162+
let meet x y = if (not int_refine_active) && x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.meet x y)
158163
let join x y = if x.BatHashcons.tag == y.BatHashcons.tag then x else lift (lift_f2 Base.join x y)
159164
let leq x y = (x.BatHashcons.tag == y.BatHashcons.tag) || lift_f2 Base.leq x y
160165
let is_top = lift_f Base.is_top
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// PARAM: --set ana.int.refinement fixpoint --enable ana.int.interval
2+
// FIXPOINT
3+
#include<assert.h>
4+
5+
int g = 0;
6+
7+
void main()
8+
{
9+
int i = 0;
10+
while (1) {
11+
i++;
12+
for (int j=0; j < 10; j++) {
13+
if (i > 100) g = 1;
14+
}
15+
if (i>9) i=0;
16+
}
17+
return;
18+
}

0 commit comments

Comments
 (0)