Skip to content

Commit 344566b

Browse files
committed
SMT2 back-end: do not flatten flattened arrays
convert_expr may flatten an array anyway, in which case flatten_array would generate select statements over bitvectors instead of arrays (as flatten_array itself invokes convert_expr to supposedly construct the array expression). Also, make sure the same flattening logic applies to 1-element structs.
1 parent bf18c17 commit 344566b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

regression/cbmc/array-function-parameters/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE broken-smt-backend
1+
CORE
22
test.c
33
--function test --min-null-tree-depth 2 --max-nondet-tree-depth 2 --bounds-check
44
^EXIT=10$

src/solvers/smt2/smt2_conv.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,16 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
31373137
else
31383138
{
31393139
if(components.size()==1)
3140-
convert_expr(expr.op0());
3140+
{
3141+
const exprt &op = expr.op0();
3142+
// may need to flatten array-theory arrays in there
3143+
if(op.type().id() == ID_array && use_array_theory(op))
3144+
flatten_array(op);
3145+
else if(op.type().id() == ID_bool)
3146+
flatten2bv(op);
3147+
else
3148+
convert_expr(op);
3149+
}
31413150
else
31423151
{
31433152
// SMT-LIB 2 concat is binary only
@@ -3148,7 +3157,7 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
31483157
exprt op=expr.operands()[i-1];
31493158

31503159
// may need to flatten array-theory arrays in there
3151-
if(op.type().id() == ID_array)
3160+
if(op.type().id() == ID_array && use_array_theory(op))
31523161
flatten_array(op);
31533162
else if(op.type().id() == ID_bool)
31543163
flatten2bv(op);

0 commit comments

Comments
 (0)