Skip to content

Commit

Permalink
Make comparison of pointers amenable to meet if they only differ in…
Browse files Browse the repository at this point in the history
… offsets
  • Loading branch information
michael-schwarz committed May 15, 2024
1 parent c1b7284 commit 3eff22f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cdomain/value/cdomains/addressDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct

let amenable_to_meet x y = match x,y with
| StrPtr _, StrPtr _ -> true
| Addr x, Addr y when Mval.equal (Mval.top_indices x) (Mval.top_indices y) -> true
| _ -> false

let leq x y = match x, y with
Expand Down
24 changes: 24 additions & 0 deletions tests/regression/27-inv_invariants/22-meet-ptrs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//PARAM: --enable ana.int.interval
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main() {
int arr[20];

int top;

int i = 2;
if(top) {
i = 8;
}

int* imprecise = &arr[i];

if(imprecise == &arr[2]) {
__goblint_check(imprecise == &arr[2]);
}

return 0;
}

0 comments on commit 3eff22f

Please sign in to comment.