Skip to content

Commit cba0035

Browse files
committed
Get minus_exprt conversion with one pointer operand working.
1 parent 2181146 commit cba0035

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,17 @@ static smt_termt convert_expr_to_smt(
724724
}
725725
else if(one_operand_pointer)
726726
{
727-
UNIMPLEMENTED_FEATURE(
728-
"convert_expr_to_smt::minus_exprt doesn't handle expressions where"
729-
"only one operand is a pointer - this is because these expressions"
730-
"are normally handled by convert_expr_to_smt::plus_exprt due to"
731-
"transformations of the expressions by previous passes bringing"
732-
"them into a form more suitably handled by that version of the function."
733-
"If you are here, this is a mistake or something went wrong before."
734-
"The expression that caused the problem is: " +
735-
minus.pretty());
727+
// It's semantically void to have an expression `3 - a` where `a`
728+
// is a pointer.
729+
INVARIANT(
730+
lhs_is_pointer,
731+
"minus expressions of pointer and integer expect lhs to be the pointer");
732+
const auto lhs_base_type = to_pointer_type(minus.lhs().type()).base_type();
733+
734+
return smt_bit_vector_theoryt::subtract(
735+
converted.at(minus.lhs()),
736+
smt_bit_vector_theoryt::multiply(
737+
converted.at(minus.rhs()), pointer_sizes.at(lhs_base_type)));
736738
}
737739
else
738740
{

0 commit comments

Comments
 (0)