diff --git a/src/analyses/base.ml b/src/analyses/base.ml index ab457ed0e5..c96106b29f 100644 --- a/src/analyses/base.ml +++ b/src/analyses/base.ml @@ -876,8 +876,11 @@ struct Address (AD.map array_start (eval_lv ~ctx st lval)) | CastE (t, Const (CStr (x,e))) -> (* VD.top () *) eval_rv ~ctx st (Const (CStr (x,e))) (* TODO safe? *) | CastE (t, exp) -> - let v = eval_rv ~ctx st exp in - VD.cast ~torg:(Cilfacade.typeOf exp) t v + (let v = eval_rv ~ctx st exp in + try + VD.cast ~torg:(Cilfacade.typeOf exp) t v + with Cilfacade.TypeOfError _ -> + VD.cast t v) | SizeOf _ | Real _ | Imag _ diff --git a/tests/regression/46-apron2/60-issue-1338.c b/tests/regression/46-apron2/60-issue-1338.c new file mode 100644 index 0000000000..899fe613b3 --- /dev/null +++ b/tests/regression/46-apron2/60-issue-1338.c @@ -0,0 +1,11 @@ +// SKIP PARAM: --set ana.activated[+] apron +#include +int main() +{ + char *ptr = malloc(2); + char s = *(ptr+0)+0; + + char *arr; + arr = malloc(8); + int tmp = (int)*(arr+0); +} \ No newline at end of file