Skip to content

Commit 7d0fbee

Browse files
committed
Fix unsoundness with large 64bit unsigned constant (closes #120)
1 parent 3164939 commit 7d0fbee

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/analyses/base.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ struct
612612
| Const (CChr x) -> eval_rv a gs st (Const (charConstToInt x)) (* char becomes int, see Cil doc/ISO C 6.4.4.4.10 *)
613613
| Const (CInt64 (num,typ,str)) ->
614614
(match str with Some x -> M.tracel "casto" "CInt64 (%s, %a, %s)\n" (Int64.to_string num) d_ikind typ x | None -> ());
615-
`Int (ID.of_int num)
615+
`Int (ID.cast_to typ (ID.of_int num))
616616
(* String literals *)
617617
| Const (CStr x) -> `Address (AD.from_string x) (* normal 8-bit strings, type: char* *)
618618
| Const (CWStr xs as c) -> (* wide character strings, type: wchar_t* *)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// PARAM: --enable ana.int.interval --enable ana.int.def_exc
2+
// issue #120
3+
#include <assert.h>
4+
5+
int main() {
6+
// should be LP64
7+
unsigned long n = 16;
8+
unsigned long size = 4912;
9+
10+
assert(!(0xffffffffffffffffUL / size < n)); // UNKNOWN (for now)
11+
}

0 commit comments

Comments
 (0)