Skip to content

Commit 98977b1

Browse files
committed
CongruenceDomain.sub: Handle case when second operand of subtraction is precisely known.
1 parent 5f1b020 commit 98977b1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/cdomain/value/cdomains/int/congruenceDomain.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,17 @@ struct
323323
match y with
324324
| None -> raise (ArithmeticOnIntegerBot (Printf.sprintf "%s op %s" (show x) (show y)))
325325
| Some (c, m) ->
326-
let m = m -: c in
327-
let y = Some (c, m) in
326+
let y =
327+
if m =: Z.zero then
328+
if no_ov then
329+
let c = Z.neg c in
330+
Some (c, m)
331+
else
332+
top_of ik
333+
else
334+
let m = m -: c in
335+
Some (c, m)
336+
in
328337
add ~no_ov ik x y
329338

330339
let sub ?no_ov ik x y =

0 commit comments

Comments
 (0)