Skip to content

Commit b88fe35

Browse files
[string-refinement] Check for char type
1 parent 1a22916 commit b88fe35

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/solvers/refinement/string_refinement.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ static void substitute_function_applications_in_equations(
226226
eq.rhs() = substitute_function_applications(eq.rhs(), generator);
227227
}
228228

229-
/// For now, any unsigned bitvector type is considered a character.
229+
/// For now, any unsigned bitvector type of width smaller or equal to 16 is
230+
/// considered a character.
230231
/// \param type: a type
231232
/// \return true if the given type represents characters
232233
bool is_char_type(const typet &type)
233234
{
234-
return type.id() == ID_unsignedbv;
235+
return type.id() == ID_unsignedbv &&
236+
to_unsignedbv_type(type).get_width() <= 16;
235237
}
236238

237239
/// Distinguish char array from other types.
@@ -1686,7 +1688,7 @@ static void initial_index_set(
16861688
{
16871689
const exprt &cur = to_process.back();
16881690
to_process.pop_back();
1689-
if(cur.id()==ID_index)
1691+
if(cur.id() == ID_index && is_char_type(cur.type()))
16901692
{
16911693
const index_exprt &index_expr = to_index_expr(cur);
16921694
const exprt &s = index_expr.array();
@@ -1732,7 +1734,7 @@ static void initial_index_set(
17321734
const auto end=axiom.premise().depth_end();
17331735
while(it!=end)
17341736
{
1735-
if(it->id()==ID_index)
1737+
if(it->id() == ID_index && is_char_type(it->type()))
17361738
{
17371739
const exprt &s=it->op0();
17381740
const exprt &i=it->op1();
@@ -1766,7 +1768,7 @@ static void update_index_set(
17661768
{
17671769
exprt cur=to_process.back();
17681770
to_process.pop_back();
1769-
if(cur.id()==ID_index)
1771+
if(cur.id() == ID_index && is_char_type(cur.type()))
17701772
{
17711773
const exprt &s=cur.op0();
17721774
const exprt &i=cur.op1();

0 commit comments

Comments
 (0)