Skip to content

Commit bdf877d

Browse files
committed
Simplify index: ensure consistent types
When computing a new offset for a byte extract, do not implicitly assume that byte-extract offsets and array index operations use exactly the same type for we don't prescribe the type to use as a byte-extract offset. Fixes: #6298
1 parent 724467c commit bdf877d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/simplify_expr_array.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ simplify_exprt::simplify_index(const index_exprt &expr)
183183
return unchanged(expr);
184184

185185
// add offset to index
186-
exprt offset = simplify_mult(mult_exprt{
187-
from_integer(*sub_size, byte_extract_expr.offset().type()), index});
186+
exprt offset = simplify_rec(mult_exprt{
187+
from_integer(*sub_size, byte_extract_expr.offset().type()),
188+
typecast_exprt::conditional_cast(
189+
index, byte_extract_expr.offset().type())});
188190
exprt final_offset =
189191
simplify_plus(plus_exprt(byte_extract_expr.offset(), offset));
190192

0 commit comments

Comments
 (0)