@@ -641,17 +641,39 @@ static smt_termt convert_expr_to_smt(
641
641
642
642
static smt_termt convert_expr_to_smt (
643
643
const minus_exprt &minus,
644
- const sub_expression_mapt &converted)
644
+ const sub_expression_mapt &converted,
645
+ const pointer_size_mapt &pointer_sizes)
645
646
{
646
647
const bool both_operands_bitvector =
647
648
can_cast_type<integer_bitvector_typet>(minus.lhs ().type ()) &&
648
649
can_cast_type<integer_bitvector_typet>(minus.rhs ().type ());
649
650
650
- if (both_operands_bitvector)
651
+ const bool lhs_is_pointer = can_cast_type<pointer_typet>(minus.lhs ().type ());
652
+ const bool rhs_is_pointer = can_cast_type<pointer_typet>(minus.rhs ().type ());
653
+
654
+ const bool both_operands_pointers = lhs_is_pointer && rhs_is_pointer;
655
+
656
+ // We don't really handle this - we just compute this to fall
657
+ // into an if-else branch that gives proper error handling information.
658
+ const bool one_operand_pointer = lhs_is_pointer || rhs_is_pointer;
659
+
660
+ if (both_operands_bitvector || both_operands_pointers)
651
661
{
652
662
return smt_bit_vector_theoryt::subtract (
653
663
converted.at (minus.lhs ()), converted.at (minus.rhs ()));
654
664
}
665
+ else if (one_operand_pointer)
666
+ {
667
+ UNIMPLEMENTED_FEATURE (
668
+ " convert_expr_to_smt::minus_exprt doesn't handle expressions where"
669
+ " only one operand is a pointer - this is because these expressions"
670
+ " are normally handled by convert_expr_to_smt::plus_exprt due to"
671
+ " transformations of the expressions by previous passes bringing"
672
+ " them into a form more suitably handled by that version of the function."
673
+ " If you are here, this is a mistake or something went wrong before."
674
+ " The expression that caused the problem is: " +
675
+ minus.pretty ());
676
+ }
655
677
else
656
678
{
657
679
UNIMPLEMENTED_FEATURE (
@@ -1455,7 +1477,7 @@ static smt_termt dispatch_expr_to_smt_conversion(
1455
1477
}
1456
1478
if (const auto minus = expr_try_dynamic_cast<minus_exprt>(expr))
1457
1479
{
1458
- return convert_expr_to_smt (*minus, converted);
1480
+ return convert_expr_to_smt (*minus, converted, pointer_sizes );
1459
1481
}
1460
1482
if (const auto divide = expr_try_dynamic_cast<div_exprt>(expr))
1461
1483
{
0 commit comments