-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize -C overflow-checks #1535
Conversation
@@ -1,36 +0,0 @@ | |||
- Feature Name: (fill me in with a unique ident, my_awesome_feature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't want to delete htis.
``` | ||
|
||
This may also be accomplished by Cargo's pending support for passing | ||
arbitrary flags to rustc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to wait for this, rather than add more ad hoc options to Cargo
This sounds amazing :D |
Is it? I'd say it's a perfectly reasonable choice for a crate to request overflow checks on all arithmetic operations except where explicitly disabled by using |
Ah, indeed, I was thinking it another way: if a crate has the option to NOT have overflow checks, then it might be a port to subtle undefined behaviour on different architectures. Edit: To elaborate, the scenario I was thinking is: even if the checks are always on on debug, the crate author might be the only person to run the crate on debug, and not uncover some bugs. If he/she has the power to opt out of the overflow checks for the release version of his/her crate, then no users ever see that crate panicking on overflow, and they see the effects of overflows as device-specific functionality. Then, as an even rarer case, some user with a different architecture uses the crate, and once in a decade, his software is going to crash, and nobody ever knows why. On the other hand, if the users are able to change the behaviour of the crate to panicking, then more people are likely to do so, and the bugs are found with a larger probability. So, I wouldn't mind if there were a per-crate option: "always panicking" OR "either panics or silently overflows, decided by downstream", as long as there is no per-crate option "always silently overflow". |
Actually, now that I think of it, it would be pretty nice if you could build with overflow-checks on or off, but an individual crate or function could opt from "downstream decides" to "always panic". Just a confirmation: as it currently stands in the RFC text, the flag |
I think that's right. If we had explicit overflow annotations in code they would take precedence. |
🔔 This RFC is now entering its week-long final comment period 🔔 |
The tools team discussed this RFC during triage the other day and the conclusion was to merge. Thanks again for the discussion! |
Tracking issue: rust-lang/rust#33134 |
Stabilize the
-C overflow-checks
command line argument.This is an easy way to turn on overflow checks in release builds
without otherwise turning on debug assertions, via the
-C debug-assertions
flag. In stable Rust today you can't get one withoutthe other.
Rendered.