@@ -70,10 +70,9 @@ void goto_symext::apply_goto_condition(
70
70
// / Try to evaluate a simple pointer comparison.
71
71
// / \param operation: ID_equal or ID_not_equal
72
72
// / \param symbol_expr: The symbol expression in the condition
73
- // / \param other_operand: The other expression in the condition - must pass
74
- // / goto_symex_is_constant, and since it is pointer-typed it must therefore
75
- // / be an address of expression, a typecast of an address of expression or a
76
- // / null pointer
73
+ // / \param other_operand: The other expression in the condition; we only support
74
+ // / an address of expression, a typecast of an address of expression or a
75
+ // / null pointer, and return an empty optionalt in all other cases
77
76
// / \param value_set: The value-set for looking up what the symbol can point to
78
77
// / \param language_mode: The language mode
79
78
// / \param ns: A namespace
@@ -90,12 +89,12 @@ static optionalt<renamedt<exprt, L2>> try_evaluate_pointer_comparison(
90
89
const constant_exprt *constant_expr =
91
90
expr_try_dynamic_cast<constant_exprt>(other_operand);
92
91
93
- INVARIANT (
94
- skip_typecast (other_operand).id () == ID_address_of ||
95
- ( constant_expr && constant_expr->get_value () == ID_NULL),
96
- " An expression that passes goto_symex_is_constant and has "
97
- " pointer-type must be an address of expression (possibly with some "
98
- " typecasts) or a null pointer " );
92
+ if (
93
+ skip_typecast (other_operand).id () != ID_address_of &&
94
+ (! constant_expr || constant_expr->get_value () != ID_NULL))
95
+ {
96
+ return {};
97
+ }
99
98
100
99
const ssa_exprt *ssa_symbol_expr =
101
100
expr_try_dynamic_cast<ssa_exprt>(symbol_expr);
0 commit comments