@@ -3139,8 +3139,13 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
31393139 out << " (ite (and " ;
31403140
31413141 // some fraction bit is not zero
3142- out << " (not (= ((_ extract " << (from_fraction_bits-1 ) << " 0) ?tcop) "
3143- " (_ bv0 " << from_fraction_bits << " )))" ;
3142+ if (from_fraction_bits == 0 )
3143+ out << " false" ;
3144+ else
3145+ {
3146+ out << " (not (= ((_ extract " << (from_fraction_bits - 1 )
3147+ << " 0) ?tcop) (_ bv0 " << from_fraction_bits << " )))" ;
3148+ }
31443149
31453150 // number negative
31463151 out << " (= ((_ extract " << (from_width-1 ) << " " << (from_width-1 )
@@ -3292,13 +3297,13 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
32923297 std::size_t to_fraction_bits=fixedbv_type.get_fraction_bits ();
32933298 std::size_t to_integer_bits=fixedbv_type.get_integer_bits ();
32943299
3295- if (src_type. id ()==ID_unsignedbv ||
3296- src_type.id ()== ID_signedbv ||
3297- src_type.id ()== ID_c_enum)
3300+ if (
3301+ src_type. id () == ID_unsignedbv || src_type.id () == ID_signedbv ||
3302+ src_type.id () == ID_c_enum || src_type. id () == ID_c_bool )
32983303 {
32993304 // integer to fixedbv
33003305
3301- std::size_t from_width= to_bitvector_type (src_type). get_width ( );
3306+ std::size_t from_width = boolbv_width (src_type);
33023307 out << " (concat " ;
33033308
33043309 if (from_width==to_integer_bits)
@@ -3318,7 +3323,7 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
33183323 " from_width should be smaller than to_integer_bits as other case "
33193324 " have been handled above" );
33203325 if (
3321- src_type.id () == ID_unsignedbv ||
3326+ src_type.id () == ID_unsignedbv || src_type. id () == ID_c_bool ||
33223327 (src_type.id () == ID_c_enum &&
33233328 to_c_enum_type (src_type).underlying_type ().id () == ID_unsignedbv))
33243329 {
0 commit comments