Skip to content

Commit fd3c5e7

Browse files
pkesselikroening
authored andcommitted
Fix bv_typet SMT2 parse bug
`bv_typet` is not supported by `numeric_cast_v`, causing multiple issues in `smt2_conv.cpp`. This fix removes inappropriate use of `bv_typet` and `ID_bv`.
1 parent 3b89651 commit fd3c5e7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ constant_exprt smt2_convt::parse_literal(
269269
if(type.id()==ID_floatbv)
270270
{
271271
const floatbv_typet &floatbv_type=to_floatbv_type(type);
272-
constant_exprt s1=parse_literal(src.get_sub()[1], bv_typet(1));
273-
constant_exprt s2=
274-
parse_literal(src.get_sub()[2], bv_typet(floatbv_type.get_e()));
275-
constant_exprt s3=
276-
parse_literal(src.get_sub()[3], bv_typet(floatbv_type.get_f()));
272+
constant_exprt s1 = parse_literal(src.get_sub()[1], unsignedbv_typet(1));
273+
constant_exprt s2 =
274+
parse_literal(src.get_sub()[2], unsignedbv_typet(floatbv_type.get_e()));
275+
constant_exprt s3 =
276+
parse_literal(src.get_sub()[3], unsignedbv_typet(floatbv_type.get_f()));
277277
// stitch the bits together
278278
std::string bits=id2string(s1.get_value())+
279279
id2string(s2.get_value())+
@@ -310,7 +310,6 @@ constant_exprt smt2_convt::parse_literal(
310310

311311
if(type.id()==ID_signedbv ||
312312
type.id()==ID_unsignedbv ||
313-
type.id()==ID_bv ||
314313
type.id()==ID_c_enum ||
315314
type.id()==ID_c_bool)
316315
{
@@ -377,7 +376,7 @@ exprt smt2_convt::parse_union(
377376
PRECONDITION(!type.components().empty());
378377
const union_typet::componentt &first=type.components().front();
379378
std::size_t width=boolbv_width(type);
380-
exprt value=parse_rec(src, bv_typet(width));
379+
exprt value = parse_rec(src, unsignedbv_typet(width));
381380
if(value.is_nil())
382381
return nil_exprt();
383382
const typecast_exprt converted(value, first.type());
@@ -416,7 +415,7 @@ exprt smt2_convt::parse_struct(
416415
{
417416
// These are just flattened, i.e., we expect to see a monster bit vector.
418417
std::size_t total_width=boolbv_width(type);
419-
exprt l=parse_literal(src, bv_typet(total_width));
418+
exprt l = parse_literal(src, unsignedbv_typet(total_width));
420419
if(!l.is_constant())
421420
return nil_exprt();
422421

@@ -457,7 +456,6 @@ exprt smt2_convt::parse_rec(const irept &src, const typet &_type)
457456
type.id()==ID_integer ||
458457
type.id()==ID_rational ||
459458
type.id()==ID_real ||
460-
type.id()==ID_bv ||
461459
type.id()==ID_fixedbv ||
462460
type.id()==ID_floatbv)
463461
{
@@ -474,7 +472,7 @@ exprt smt2_convt::parse_rec(const irept &src, const typet &_type)
474472
{
475473
// these come in as bit-vector literals
476474
std::size_t width=boolbv_width(type);
477-
constant_exprt bv_expr=parse_literal(src, bv_typet(width));
475+
constant_exprt bv_expr = parse_literal(src, unsignedbv_typet(width));
478476

479477
mp_integer v = numeric_cast_v<mp_integer>(bv_expr);
480478

0 commit comments

Comments
 (0)