Skip to content

Commit 9df171e

Browse files
committed
Simplify byte extract: support signed and unsigned offsets
The minimized example from diffblue#7357 resulted in an invariant failure in `solvers/flattening/boolbv_add_sub.cpp`, reporting "add/sub with mixed types." This was caused by simplifying nested byte-extract operations where one used unsigned offsets and the other one signed. Since we do not required a particular type for byte-extract offsets we must cope with different offset types when folding nested byte-extract operations into a single one.
1 parent e7787ad commit 9df171e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/simplify_expr.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,10 @@ simplify_exprt::simplify_byte_extract(const byte_extract_exprt &expr)
16601660
{
16611661
auto tmp = expr;
16621662

1663-
tmp.offset() = simplify_plus(
1664-
plus_exprt(to_byte_extract_expr(expr.op()).offset(), expr.offset()));
1663+
tmp.offset() = simplify_rec(plus_exprt(
1664+
typecast_exprt::conditional_cast(
1665+
to_byte_extract_expr(expr.op()).offset(), expr.offset().type()),
1666+
expr.offset()));
16651667
tmp.op() = to_byte_extract_expr(expr.op()).op();
16661668

16671669
return changed(simplify_byte_extract(tmp)); // recursive call

0 commit comments

Comments
 (0)