Skip to content
Discussion options

You must be logged in to vote

@xd009642

I'm planning on switching a bunch of my code to use these where it should be safe, but now I'm wondering if I'm wrong can kani catch it?

Short answer: do not treat Kani as a check that algebraic_add (and friends) are safe to switch to. It can still help with IEEE-shaped bugs around the call. It will not model the extra freedom those operators give LLVM.

f32::algebraic_add is not IEEE +. It is a rustc/LLVM op with algebraic flags (reassociate, contract, reciprocal, and similar). The compiler may rewrite (a + b) + c into a + (b + c) or fuse a multiply-add. That rewrite is the point of the API, and it is also where a "this should be safe" assumption dies.

Kani lowers Rust to GOTO…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by xd009642
Comment options

You must be logged in to vote
2 replies
@xd009642
Comment options

@xd009642
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants