-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement arithmetic overflow changes #22532
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
(I'm actually still running |
current PR gets to |
okay, now |
Now
(looking) |
Addressed The Next up:
|
I think I've addressed the two problems above, but now I need to rebuild core. Q: Was this a bug in
|
@pnkfelix that looks like a legitimate bug fix to me |
Okay, Now I get to:
|
Well, this is a funny one; it obviously might overflow (about half the time, right?):
|
Current state now:
Update: oh, sweet, we've started hitting cases where |
Okay, we get past Next, compile-fail, we do surprisingly well there too (probably too well, again I say):
|
Now we get past
and then Update: Actually, I don't know what's going on with this test. It does not seem to be hitting a panic. Maybe I have broken something without realizing it. |
(I can't figure out why the |
However, all together, these changes appear to let me pass through |
236c6d6
to
db82f27
Compare
let check_overflow = if let Some(v) = tcx.sess.opts.debugging_opts.force_overflow_checks { | ||
v | ||
} else { | ||
!attr::contains_name(&krate.config[], "ndebug") |
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.
(this may need to be changed to be based on optimization level rather than ndebug
)
e6da3e6
to
c8493df
Compare
However, I left the ICEs rather than switching to nicer error reporting there; these cases *should* be detected prior to hitting trans, and thus ICE'ing here is appropriate. (So why switch to `eval_const_expr_partial`? Because I want to try to eliminate all uses of `eval_const_expr` entirely.)
Added pair of regression tests that I should have made when I thought of doing this in the first place.
Suggestion was here: rust-lang#22532 (comment)
@bors p=1 r=pnkfelix,eddyb cefd82f |
After reviewing the code and thinking it over, I decided the only sane thing to do here would be to act like either over- or underflow could be occurring, and to use saturated arithmetic in both cases. See commit 243c516 |
89f3eeb
to
01208ab
Compare
See buildlog here for evidence of such occurring: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/3910/steps/test/logs/stdio
Rebase and follow-through on work done by @cmr and @Aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
Aha! I have managed to now reproduce it: I had to run |
Wait, we run our 32bit stuff on 64bit systems? Not 32bit systems/emulators? I can understand the crosscompile on 64bit, but I thought the builders would shove it into qemu or something for testing. |
\o/ |
Mystery solved: It appears it was indeed an overflow triggered from this calcuation:
(So, is 64-bit linux just allowing for the stack to start at much higher addresses than one would expect? I assume that it would stop a 32-bit stack pointer from actually overflowing...) |
The previous code only detected overflow to exactly zero (`u64::MAX + 1`). Tested on `multirust override nightly-2015-03-01` (before rust-lang/rust#22532)
Rebase and follow-through on work done by @cmr and @Aatch.
Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed.
The checks for division, remainder and bit-shifting have not been implemented yet.
See also PR #20795, as well as the tracking issue #22020
cc @Aatch ; cc @nikomatsakis