Skip to content

ITE and binary relations are constant when all operands are constants #7569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions regression/cbmc/constant_folding3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int main(void)
{
int x;
int plus_one_is_null = &x + 1 == (int *)0 ? 1 : 0;
__CPROVER_assert(plus_one_is_null != 2, "cannot be 2");

return 0;
}
9 changes: 9 additions & 0 deletions regression/cbmc/constant_folding3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE new-smt-backend
main.c

^Generated 1 VCC\(s\), 0 remaining after simplification$
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
8 changes: 6 additions & 2 deletions src/util/expr_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,12 @@ bool is_constantt::is_constant(const exprt &expr) const
expr.id() == ID_typecast || expr.id() == ID_array_of ||
expr.id() == ID_plus || expr.id() == ID_mult || expr.id() == ID_array ||
expr.id() == ID_with || expr.id() == ID_struct || expr.id() == ID_union ||
expr.id() == ID_empty_union ||
expr.id() == ID_byte_update_big_endian ||
expr.id() == ID_empty_union || expr.id() == ID_equal ||
expr.id() == ID_notequal || expr.id() == ID_lt || expr.id() == ID_le ||
expr.id() == ID_gt || expr.id() == ID_ge || expr.id() == ID_if ||
expr.id() == ID_not || expr.id() == ID_and || expr.id() == ID_or ||
expr.id() == ID_bitnot || expr.id() == ID_bitand || expr.id() == ID_bitor ||
expr.id() == ID_bitxor || expr.id() == ID_byte_update_big_endian ||
expr.id() == ID_byte_update_little_endian)
{
return std::all_of(
Expand Down