Skip to content

Commit 2782fc1

Browse files
Replace to_integer with numeric_cast in boolbv_index
1 parent ca235a9 commit 2782fc1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/solvers/flattening/boolbv_index.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@ bvt boolbvt::convert_index(const index_exprt &expr)
6161
}
6262

6363
// Must have a finite size
64-
mp_integer array_size;
65-
if(to_integer(array_type.size(), array_size))
66-
throw "failed to convert array size";
67-
68-
// see if the index address is constant
69-
// many of these are compacted by simplify_expr
70-
// but variable location writes will block this
71-
mp_integer index_value;
72-
if(!to_integer(index, index_value))
73-
return convert_index(array, index_value);
64+
mp_integer array_size = numeric_cast_v<mp_integer>(array_type.size());
65+
66+
{
67+
// see if the index address is constant
68+
// many of these are compacted by simplify_expr
69+
// but variable location writes will block this
70+
auto maybe_index_value = numeric_cast<mp_integer>(index);
71+
if(maybe_index_value.has_value())
72+
{
73+
return convert_index(array, maybe_index_value.value());
74+
}
75+
}
7476

7577
// Special case : arrays of one thing (useful for constants)
7678
// TODO : merge with ACTUAL_ARRAY_HACK so that ranges of the same

0 commit comments

Comments
 (0)