Skip to content

Commit 27bc557

Browse files
committed
division-by-zero on float
This disables the division-by-zero check for floating-point operations. Division by zero on floating-point numbers is defined behavior when using IEEE 754.
1 parent 9411c77 commit 27bc557

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/ansi-c/goto_check_c.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,15 @@ void goto_check_ct::check_rec_div(
18501850
const div_exprt &div_expr,
18511851
const guardt &guard)
18521852
{
1853-
div_by_zero_check(to_div_expr(div_expr), guard);
1853+
if(div_expr.type().id() == ID_signedbv ||
1854+
div_expr.type().id() == ID_unsignedbv ||
1855+
div_expr.type().id() == ID_c_bool)
1856+
{
1857+
// Division by zero is undefined behavior for all integer types.
1858+
// Division by zero is defined behavior for
1859+
// floating-point types if IEEE 754 is used.
1860+
div_by_zero_check(to_div_expr(div_expr), guard);
1861+
}
18541862

18551863
if(div_expr.type().id() == ID_signedbv)
18561864
integer_overflow_check(div_expr, guard);

0 commit comments

Comments
 (0)