Skip to content

Commit b830957

Browse files
committed
Base.eval_rv: Do not remove cast if at least one of the arguments is of integer type
1 parent 0fe8b96 commit b830957

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/analyses/base.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,8 @@ struct
720720
| BinOp (op, (CastE (t1, e1) as c1), (CastE (t2, e2) as c2), typ) when typeSig t1 = typeSig t2 && (op = Eq || op = Ne) ->
721721
let a1 = eval_rv a gs st e1 in
722722
let a2 = eval_rv a gs st e2 in
723-
let both_arith_type = isArithmeticType (typeOf e1) && isArithmeticType (typeOf e2) in
724-
let is_safe = VD.equal a1 a2 || VD.is_safe_cast t1 (typeOf e1) && VD.is_safe_cast t2 (typeOf e2) && not both_arith_type in
723+
let one_arith_type = isArithmeticType (typeOf e1) || isArithmeticType (typeOf e2) in
724+
let is_safe = VD.equal a1 a2 || VD.is_safe_cast t1 (typeOf e1) && VD.is_safe_cast t2 (typeOf e2) && not one_arith_type in
725725
M.tracel "cast" "remove cast on both sides for %a? -> %b\n" d_exp exp is_safe;
726726
if is_safe then (* we can ignore the casts if the values are equal anyway, or if the casts can't change the value *)
727727
eval_rv a gs st (BinOp (op, e1, e2, typ))

0 commit comments

Comments
 (0)