Skip to content

Commit 9f1aa87

Browse files
authored
Merge pull request #3639 from diffblue/smt2-with-full-size
smt2: fix encoding of with expressions
2 parents 6cd0fb3 + fbc74de commit 9f1aa87

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

scripts/delete_failing_smt2_solver_tests

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ rm Float8/test.desc
3636
rm Linking4/test.desc
3737
rm Linking7/test.desc
3838
rm Linking7/member-name-mismatch.desc
39-
rm Malloc19/test.desc
4039
rm Malloc23/test.desc
4140
rm Malloc24/test.desc
4241
rm Memory_leak2/test.desc
4342
rm Multi_Dimensional_Array2/test.desc
4443
rm Overflow_Leftshift1/test.desc
4544
rm Overflow_Subtraction1/test.desc
46-
rm Pointer_Arithmetic10/test.desc
4745
rm Pointer_Arithmetic11/test.desc
4846
rm Pointer_byte_extract2/test.desc
4947
rm Pointer_byte_extract3/test.desc
@@ -87,7 +85,6 @@ rm pointer-function-parameters-struct-simple-recursion-2/test.desc
8785
rm pointer-function-parameters-struct-simple-recursion-3/test.desc
8886
rm scanf1/test.desc
8987
rm stack-trace/test.desc
90-
rm struct10/test.desc
9188
rm struct6/test.desc
9289
rm struct7/test.desc
9390
rm struct9/test.desc

src/solvers/smt2/smt2_conv.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,7 @@ void smt2_convt::convert_with(const with_exprt &expr)
34763476
{
34773477
std::size_t s=expr.operands().size();
34783478

3479-
// strip of the trailing two operands
3479+
// strip off the trailing two operands
34803480
with_exprt tmp = expr;
34813481
tmp.operands().resize(s-2);
34823482

@@ -3515,7 +3515,7 @@ void smt2_convt::convert_with(const with_exprt &expr)
35153515
std::size_t sub_width=boolbv_width(array_type.subtype());
35163516
std::size_t index_width=boolbv_width(expr.where().type());
35173517

3518-
// We mask out the updated bit with AND,
3518+
// We mask out the updated bits with AND,
35193519
// and then OR-in the shifted new value.
35203520

35213521
out << "(let ((distance? ";
@@ -3540,15 +3540,16 @@ void smt2_convt::convert_with(const with_exprt &expr)
35403540

35413541
out << "(bvor ";
35423542
out << "(bvand ";
3543-
out << "(bvlshr (_ bv" << power(2, array_width)-1 << " "
3544-
<< array_width << ") ";
3545-
out << "distance?) ";
3543+
out << "(bvnot ";
3544+
out << "(bvshl (_ bv" << power(2, sub_width) - 1 << " " << array_width
3545+
<< ") ";
3546+
out << "distance?)) "; // bvnot, bvlshl
35463547
convert_expr(expr.old());
35473548
out << ") "; // bvand
3548-
out << "(bvlshr ";
3549+
out << "(bvshl ";
35493550
out << "((_ zero_extend " << array_width-sub_width << ") ";
35503551
convert_expr(expr.new_value());
3551-
out << ") distance?)))"; // zero_extend, bvlshr, bvor, let
3552+
out << ") distance?)))"; // zero_extend, bvshl, bvor, let
35523553
}
35533554
}
35543555
else if(expr_type.id()==ID_struct)
@@ -3588,8 +3589,9 @@ void smt2_convt::convert_with(const with_exprt &expr)
35883589

35893590
if(m.width==struct_width)
35903591
{
3591-
// the struct is the same as the member, no concat needed
3592-
out << "?withop";
3592+
// the struct is the same as the member, no concat needed,
3593+
// ?withop won't be used
3594+
convert_expr(value);
35933595
}
35943596
else if(m.offset==0)
35953597
{

0 commit comments

Comments
 (0)