From 37ca5fba47b85ba3f0170a3e81928fc099a4959e Mon Sep 17 00:00:00 2001
From: Valentin Perrelle <valentin.perrelle@cea.fr>
Date: Thu, 28 Mar 2024 03:19:48 +0100
Subject: [PATCH] [Eva] evast: fix a bug in constant folding where integer
 casts did not wrap their inputs

---
 src/plugins/eva/ast/evast_builder.ml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/plugins/eva/ast/evast_builder.ml b/src/plugins/eva/ast/evast_builder.ml
index cce0ba0900a..e30e1d0d6af 100644
--- a/src/plugins/eva/ast/evast_builder.ml
+++ b/src/plugins/eva/ast/evast_builder.ml
@@ -131,7 +131,8 @@ let integer ?kind i = (* TODO: mathematical unbounded integer *)
       then Cil_types.IInt
       else Cil.intKindForValue i false
   in
-  mk_exp (Const (CInt64 (i, kind, None)))
+  let i', _truncated = Cil.truncateInteger64 kind i in
+  mk_exp (Const (CInt64 (i', kind, None)))
 
 let int ?kind i =
   integer ?kind (Integer.of_int i)
-- 
GitLab