3 ms·
That's kind of at odds with Rust guarantee that your code never breaks.
by fluffything 7y ago
That's kind of at odds with Rust guarantee that your code never breaks.
- stefs 7y agorust doesn't guarantee anything if you opt out of the guarantees. two examples that come to mind: unsafe and maybe bounds checks in release mode. fastmath is probably different anyway, as the "breaking" is on a floating point logic level, as in: results become imprecise, but not exactly "wrong" - as in undefined behaviour. but i don't know fastmath, so i might be wrong.
- steveklabnik 7y ago(bounds checks are not removed in release mode, you have to use unsafe to not have the bounds check) On the /r/rust thread, folks provided examples of why fastmath would produce UB in safe Rust.
- stefs 7y agoah, i think i meant overflow checks. and thanks for the pointer, i'll have a look.
- steveklabnik 7y agoah yes, overflow checks are not in release mode today. They may be in the future. And overflow isn't UB, it's two's compliment wrapping.
- _bxg1 7y agoTechnically Rust only guarantees memory-safety (and only outside of unsafe!{}). It has many features that aid in other kinds of safety - strongly encouraging you to unwrap Option<> and Result<>, requiring all match cases to be covered, allowing for lots of strategic immutability, etc. But it doesn't guarantee that kind of correctness.
- fluffything 7y agoThat's not correct. Safe Rust is advertised as sound, and Rust defines that as "safe Rust programs do not exhibit undefined behavior". Undefined behavior is a much larger term than just memory safety, and include things like thread safety, const safety, unwind safety, etc.