Skip to content

Commit 81e2c26

Browse files
author
Daniel Kroening
committed
boolbvt::convert_constant is now independent of bitvector representation
1 parent ec8b34d commit 81e2c26

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/solvers/flattening/boolbv_constant.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,12 @@ bvt boolbvt::convert_constant(const constant_exprt &expr)
7878
expr_type.id()==ID_c_bit_field ||
7979
expr_type.id()==ID_incomplete_c_enum)
8080
{
81-
const std::string &binary=id2string(expr.get_value());
82-
83-
if(binary.size()!=width)
84-
{
85-
error().source_location=expr.find_source_location();
86-
error() << "wrong value length in constant: "
87-
<< expr.pretty() << eom;
88-
throw 0;
89-
}
81+
auto value = bv2integer(id2string(expr.get_value()), width, false);
9082

9183
for(std::size_t i=0; i<width; i++)
9284
{
93-
bool bit=(binary[binary.size()-i-1]=='1');
85+
const bool bit=value.is_odd();
86+
value/=2;
9487
bv[i]=const_literal(bit);
9588
}
9689

0 commit comments

Comments
 (0)