Skip to content

Commit d87dd23

Browse files
authored
remove flag float-overflow-check (#3873)
Resolves #3620 Removing default flag float overflow check, which reports overflow for arithmetic operations over floating-point numbers that result in +/-Inf. This doesn't panic in Rust and it shouldn't be consider a verification failure by default. Users can enable them using --cbmc-args as and when required. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 380b1fb commit d87dd23

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

kani-driver/src/call_cbmc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ impl KaniSession {
233233
args.push("--no-pointer-check".into());
234234
}
235235
if self.args.checks.overflow_on() {
236-
args.push("--float-overflow-check".into());
237236
args.push("--nan-check".into());
238237

239238
// TODO: Implement conversion checks as an optional check.

tests/ui/cbmc_checks/float-overflow/check_message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
//
4+
// kani-flags: --enable-unstable --cbmc-args --float-overflow-check
45
// Check we don't print temporary variables as part of CBMC messages.
56
extern crate kani;
67

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERIFICATION:- SUCCESSFUL
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
//
4+
// This test verifies that Kani does not report floating-point overflow by default
5+
// for operations that result in +/-Infinity.
6+
extern crate kani;
7+
8+
// Use the result so rustc doesn't optimize them away.
9+
fn dummy(result: f32) -> f32 {
10+
result
11+
}
12+
13+
#[kani::proof]
14+
fn main() {
15+
let a = kani::any_where(|&x: &f32| x.is_finite());
16+
let b = kani::any_where(|&x: &f32| x.is_finite());
17+
18+
dummy(a + b);
19+
dummy(a - b);
20+
dummy(a * b);
21+
dummy(-a);
22+
}

0 commit comments

Comments
 (0)