4 ms·
I'd prefer for Rust to opt for correctness/bug-freeness over performance, even in release builds. If you are doing number crunching you should have to opt out o
by bobbylarrybobby 2y ago
I'd prefer for Rust to opt for correctness/bug-freeness over performance, even in release builds. If you are doing number crunching you should have to opt out of these checks.
- mustache_kimono 2y ago> I'd prefer for Rust to opt for correctness/bug-freeness over performance, even in release builds. If you are doing number crunching you should have to opt out of these checks. You can turn those checks on, in release mode, of course: https://doc.rust-lang.org/rustc/codegen-options/index.html#overflow-checks https://doc.rust-lang.org/rustc/codegen-options/index.html#o... But I think the behavior on overflow is to "panic!()" (terminate immediately)? So -- I guess from my POV I wouldn't in release mode. I just think that tradeoff isn't generally worth it, but again, you can turn that behavior on.
- steveklabnik 2y agopanics do not terminate immediately; they unwind the stack, and if they’re not caught, they terminate the current thread, not the process.
- mustache_kimono 2y ago> panics do not terminate immediately; they unwind the stack, and if they’re not caught, they terminate the current thread, not the process. I don't disagree though this point is a little pedantic. I suppose the docs also need an update? See: https://doc.rust-lang.org/std/macro.panic.html https://doc.rust-lang.org/std/macro.panic.html "This allows a *program to terminate immediately* and provide feedback to the caller of the program." Now, I don't think so, because program death is usually what this type of panic means. And my point remains, without more, this probably isn't the behavior one wants in release mode. But, yes, also perhaps an even better behavior is turning on checks, catching the panic, and logging it with others.
- steveklabnik 2y agoI don't disagree that it could use revising, but it's technically correct: it allows but does not require. If you've configured panic=abort, it will abort the program instead of unwind, but that's not the default.