Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upStabilize -C overflow-checks #1535
Conversation
sfackler
reviewed
Mar 9, 2016
| @@ -1,36 +0,0 @@ | |||
| - Feature Name: (fill me in with a unique ident, my_awesome_feature) | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
added
the
T-dev-tools
label
Mar 10, 2016
nrc
assigned
brson
Mar 13, 2016
nrc
reviewed
Mar 13, 2016
| ``` | ||
|
|
||
| This may also be accomplished by Cargo's pending support for passing | ||
| arbitrary flags to rustc. |
This comment has been minimized.
This comment has been minimized.
nrc
reviewed
Mar 13, 2016
| [alternatives]: #alternatives | ||
|
|
||
| The flag could instead be tied to crates such that any time code from | ||
| that crate is inlined/monomorphized it turns on overflow checks. |
This comment has been minimized.
This comment has been minimized.
nrc
Mar 13, 2016
Member
I would like to hear people's opinions on this - it seems significant, but I don't have a good idea of how significant.
This comment has been minimized.
This comment has been minimized.
golddranks
Mar 14, 2016
I'd imagine that if the option was crate-specific, that would be an incentive for the crate authors to rely on specific overflow semantics, which is undesirable.
This comment has been minimized.
This comment has been minimized.
|
This sounds amazing :D |
This comment has been minimized.
This comment has been minimized.
main--
commented
Mar 15, 2016
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 |
This comment has been minimized.
This comment has been minimized.
golddranks
commented
Mar 15, 2016
|
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". |
This comment has been minimized.
This comment has been minimized.
golddranks
commented
Mar 15, 2016
|
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 |
This comment has been minimized.
This comment has been minimized.
I think that's right. If we had explicit overflow annotations in code they would take precedence. |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added
the
final-comment-period
label
Apr 5, 2016
This comment has been minimized.
This comment has been minimized.
|
The tools team discussed this RFC during triage the other day and the conclusion was to merge. Thanks again for the discussion! |
alexcrichton
referenced this pull request
Apr 21, 2016
Closed
Tracking issue for -C overflow-checks #33134
alexcrichton
merged commit 65fcd92
into
rust-lang:master
Apr 21, 2016
This comment has been minimized.
This comment has been minimized.
|
Tracking issue: rust-lang/rust#33134 |
brson commentedMar 9, 2016
Stabilize the
-C overflow-checkscommand 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-assertionsflag. In stable Rust today you can't get one withoutthe other.
Rendered.