Skip to content

Commit a8b1e8e

Browse files
Changing assert for PRECONDITION and UNREACHABLE in float to string conversion
1 parent 5c71733 commit a8b1e8e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/solvers/refinement/string_constraint_generator_float.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ exprt get_magnitude(const exprt &src, const ieee_float_spect &spec)
5555
exprt get_significand(
5656
const exprt &src, const ieee_float_spect &spec, const typet &type)
5757
{
58-
assert(type.id()==ID_unsignedbv);
59-
assert(to_unsignedbv_type(type).get_width()>spec.f);
58+
PRECONDITION(type.id()==ID_unsignedbv);
59+
PRECONDITION(to_unsignedbv_type(type).get_width()>spec.f);
6060
typecast_exprt magnitude(get_magnitude(src, spec), type);
6161
exprt exponent=get_exponent(src, spec);
6262
equal_exprt all_zeros(exponent, from_integer(0, exponent.type()));
@@ -71,14 +71,11 @@ exprt constant_float(const double f, const ieee_float_spect &float_spec)
7171
{
7272
ieee_floatt fl(float_spec);
7373
if(float_spec==ieee_float_spect::single_precision())
74-
{
7574
fl.from_float(f);
76-
}
77-
else
78-
{
79-
assert(float_spec==ieee_float_spect::double_precision());
75+
else if(float_spec==ieee_float_spect::double_precision())
8076
fl.from_double(f);
81-
}
77+
else
78+
UNREACHABLE;
8279
return fl.to_expr();
8380
}
8481

@@ -99,8 +96,8 @@ exprt round_expr_to_zero(const exprt &f)
9996
/// \return An expression representing floating point multiplication.
10097
exprt floatbv_mult(const exprt &f, const exprt &g)
10198
{
99+
PRECONDITION(f.type()==g.type());
102100
ieee_floatt::rounding_modet rounding=ieee_floatt::ROUND_TO_EVEN;
103-
assert(f.type()==g.type());
104101
exprt mult(ID_floatbv_mult, f.type());
105102
mult.copy_to_operands(f);
106103
mult.copy_to_operands(g);
@@ -209,9 +206,9 @@ string_exprt string_constraint_generatort::add_axioms_from_float(
209206
string_exprt string_constraint_generatort::add_axioms_for_fractional_part(
210207
const exprt &i, size_t max_size, const refined_string_typet &ref_type)
211208
{
212-
string_exprt res=fresh_string(ref_type);
209+
PRECONDITION(i.type().id()==ID_signedbv);
213210
const typet &type=i.type();
214-
assert(type.id()==ID_signedbv);
211+
string_exprt res=fresh_string(ref_type);
215212
exprt ten=from_integer(10, type);
216213
const typet &char_type=ref_type.get_char_type();
217214
const typet &index_type=ref_type.get_index_type();

0 commit comments

Comments
 (0)