Skip to content

Commit 897034a

Browse files
committed
Simplify equality of address-of-string-constant
The back-end assumes that each string is a singleton and, therefore, taking the address of a particular string constant will always result in the same value. The simplifier can use this information. Fixes: #6966
1 parent 026931f commit 897034a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util/simplify_expr_pointer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ simplify_exprt::resultt<> simplify_exprt::simplify_inequality_address_of(
467467
{
468468
return make_boolean_expr(expr.id() != ID_equal);
469469
}
470+
else if(
471+
tmp0_object.id() == ID_string_constant &&
472+
tmp1_object.id() == ID_string_constant && tmp0_object == tmp1_object)
473+
{
474+
return make_boolean_expr(expr.id() == ID_equal);
475+
}
470476

471477
return unchanged(expr);
472478
}

0 commit comments

Comments
 (0)