Skip to content

Commit 40fb6a0

Browse files
committed
Don't warn on array_of_expr with zero length
These result from array_set instructions, which when targeting variable-length arrays can end up targeting zero-sized arrays.
1 parent ae74767 commit 40fb6a0

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/solvers/flattening/boolbv_array_of.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ bvt boolbvt::convert_array_of(const array_of_exprt &expr)
2525
std::size_t width=boolbv_width(array_type);
2626

2727
if(width==0)
28-
return conversion_failed(expr);
28+
{
29+
// A zero-length array is acceptable;
30+
// an element with unknown size is not.
31+
if(boolbv_width(array_type.subtype())==0)
32+
return conversion_failed(expr);
33+
else
34+
return bvt();
35+
}
2936

3037
const exprt &array_size=array_type.size();
3138

src/solvers/flattening/boolbv_with.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ bvt boolbvt::convert_with(const exprt &expr)
3737
std::size_t width=boolbv_width(expr.type());
3838

3939
if(width==0)
40-
return conversion_failed(expr);
40+
{
41+
// A zero-length array is acceptable:
42+
if(expr.type().id()==ID_array && boolbv_width(expr.type().subtype())!=0)
43+
return bvt();
44+
else
45+
return conversion_failed(expr);
46+
}
4147

4248
if(bv.size()!=width)
4349
{

0 commit comments

Comments
 (0)