Skip to content

Commit 4880335

Browse files
authored
Merge pull request #6142 from tautschnig/pointer-comparison-simplify
simplify_inequality_address_of only supports (not)equal
2 parents 53564c1 + b1fcc9a commit 4880335

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int *p1 = malloc(sizeof(int));
7+
8+
assert(p1 < p1 + 1);
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

src/util/simplify_expr_int.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,8 @@ simplify_exprt::simplify_inequality(const binary_relation_exprt &expr)
12421242
// see if we are comparing pointers that are address_of
12431243
if(
12441244
skip_typecast(tmp0).id() == ID_address_of &&
1245-
skip_typecast(tmp1).id() == ID_address_of)
1245+
skip_typecast(tmp1).id() == ID_address_of &&
1246+
(expr.id() == ID_equal || expr.id() == ID_notequal))
12461247
{
12471248
return simplify_inequality_address_of(expr);
12481249
}

0 commit comments

Comments
 (0)