Skip to content

Commit 4d21a1d

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 1a0e682 commit 4d21a1d

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
@@ -3142,7 +3142,16 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
31423142
else
31433143
{
31443144
if(components.size()==1)
3145-
convert_expr(expr.op0());
3145+
{
3146+
const exprt &op = expr.op0();
3147+
// may need to flatten array-theory arrays in there
3148+
if(op.type().id() == ID_array && use_array_theory(op))
3149+
flatten_array(op);
3150+
else if(op.type().id() == ID_bool)
3151+
flatten2bv(op);
3152+
else
3153+
convert_expr(op);
3154+
}
31463155
else
31473156
{
31483157
// SMT-LIB 2 concat is binary only
@@ -3153,7 +3162,7 @@ void smt2_convt::convert_struct(const struct_exprt &expr)
31533162
exprt op=expr.operands()[i-1];
31543163

31553164
// may need to flatten array-theory arrays in there
3156-
if(op.type().id() == ID_array)
3165+
if(op.type().id() == ID_array && use_array_theory(op))
31573166
flatten_array(op);
31583167
else if(op.type().id() == ID_bool)
31593168
flatten2bv(op);

0 commit comments

Comments
 (0)