Skip to content

Commit 1a4e3a9

Browse files
committed
SMT back-end: fix type when RHS will be flattened
When the right-hand side is a member expression the type has to be a bit vector (unless data types are used).
1 parent 5b0e207 commit 1a4e3a9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

regression/cbmc/Array_operations1/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ void test_copy()
5454
__CPROVER_array_copy(array1, array3);
5555
__CPROVER_assert(array1[10] == 11, "array1[10] is OK");
5656
__CPROVER_assert(array1[99] == 42, "expected to fail");
57+
58+
int a[1];
59+
struct
60+
{
61+
int a[1];
62+
} s;
63+
__CPROVER_array_copy(a, s.a);
64+
__CPROVER_assert(a[0] == s.a[0], "array copied");
5765
}
5866

5967
void test_replace()

src/solvers/smt2/smt2_conv.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4786,7 +4786,17 @@ void smt2_convt::set_to(const exprt &expr, bool value)
47864786
{
47874787
out << "(define-fun " << smt2_identifier;
47884788
out << " () ";
4789-
convert_type(equal_expr.lhs().type());
4789+
if(
4790+
equal_expr.lhs().type().id() != ID_array ||
4791+
use_array_theory(prepared_rhs))
4792+
{
4793+
convert_type(equal_expr.lhs().type());
4794+
}
4795+
else
4796+
{
4797+
std::size_t width = boolbv_width(equal_expr.lhs().type());
4798+
out << "(_ BitVec " << width << ")";
4799+
}
47904800
out << ' ';
47914801
convert_expr(prepared_rhs);
47924802
out << ')' << '\n';

0 commit comments

Comments
 (0)