Skip to content

Commit 014188e

Browse files
authored
Merge pull request #7569 from tautschnig/feature/more-constants
ITE and binary relations are constant when all operands are constants
2 parents de5f29c + 0289d31 commit 014188e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int main(void)
2+
{
3+
int x;
4+
int plus_one_is_null = &x + 1 == (int *)0 ? 1 : 0;
5+
__CPROVER_assert(plus_one_is_null != 2, "cannot be 2");
6+
7+
return 0;
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE new-smt-backend
2+
main.c
3+
4+
^Generated 1 VCC\(s\), 0 remaining after simplification$
5+
^VERIFICATION SUCCESSFUL$
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring

src/util/expr_util.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ bool is_constantt::is_constant(const exprt &expr) const
239239
expr.id() == ID_typecast || expr.id() == ID_array_of ||
240240
expr.id() == ID_plus || expr.id() == ID_mult || expr.id() == ID_array ||
241241
expr.id() == ID_with || expr.id() == ID_struct || expr.id() == ID_union ||
242-
expr.id() == ID_empty_union ||
243-
expr.id() == ID_byte_update_big_endian ||
242+
expr.id() == ID_empty_union || expr.id() == ID_equal ||
243+
expr.id() == ID_notequal || expr.id() == ID_lt || expr.id() == ID_le ||
244+
expr.id() == ID_gt || expr.id() == ID_ge || expr.id() == ID_if ||
245+
expr.id() == ID_not || expr.id() == ID_and || expr.id() == ID_or ||
246+
expr.id() == ID_bitnot || expr.id() == ID_bitand || expr.id() == ID_bitor ||
247+
expr.id() == ID_bitxor || expr.id() == ID_byte_update_big_endian ||
244248
expr.id() == ID_byte_update_little_endian)
245249
{
246250
return std::all_of(

0 commit comments

Comments
 (0)