Skip to content

Commit 7aaff0d

Browse files
authored
Merge pull request #7252 from tautschnig/bugfixes/array-lhs
SMT back-end: fix type when RHS will be flattened
2 parents a7a7d79 + 09cd9ac commit 7aaff0d

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

regression/cbmc/Array_operations1/full-slice.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ main.c
1010
^\[test_unequal\.assertion\.4\] .* expected to fail: FAILURE
1111
^\[test_unequal\.assertion\.5\] .* expected to fail: FAILURE
1212
^\[test_unequal\.assertion\.6\] .* expected to fail: FAILURE
13-
^\*\* 5 of 14 failed
13+
^\*\* 5 of 15 failed
1414
^VERIFICATION FAILED$
1515
--
1616
^warning: ignoring

regression/cbmc/Array_operations1/main.c

+8
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()

regression/cbmc/Array_operations1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ main.c
1010
^\[test_unequal\.assertion\.4\] .* expected to fail: FAILURE
1111
^\[test_unequal\.assertion\.5\] .* expected to fail: FAILURE
1212
^\[test_unequal\.assertion\.6\] .* expected to fail: FAILURE
13-
^\*\* 5 of 14 failed
13+
^\*\* 5 of 15 failed
1414
^VERIFICATION FAILED$
1515
--
1616
^warning: ignoring

src/solvers/smt2/smt2_conv.cpp

+11-1
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)