Uh oh!
There was an error while loading. Please reload this page.
overflowing-checking for rhs of shift operators - #23536
Conversation
rust-highfive
commented
Mar 19, 2015
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
pnkfelix
commented
Mar 19, 2015
There was a problem hiding this comment.
ah, this whole sub-block is debugging code that is no longer needed; I will remove it.
pnkfelix
commented
Mar 20, 2015
One of the tests in this PR uncovered #23551, so don't attempt to merge this until that has a fix (or until I revise the test to sidestep that bug). |
This includes a slight refactoring of the `cast_shift_rhs` and related functions in `trans::base`, so that I can call them from much later in the compiler's control flow (so that we can clearly dilineate where automatic conversions of the RHS occur, versus where we check it). The rhs-checking and fallback-masking is generalized to 8- and 16-bit values, and the fallback-masking is turned on unconditionally. Fixrust-lang#10183. Is this a [breaking-change]? I would argue it is not; it only adds a strict definition to what was previously undefined behavior; however, there might be code that was e.g. assuming that `1_i8 << 17` yields 0. (This happens in certain contexts and at certain optimization levels.)
Note the tests have been revised to match new semantics for 8- and 16-bit values.
1beaee8 to
61ff823Comparepnkfelix
commented
Mar 20, 2015
Okay, after discovering that #23551 was a duplicate of #10183 and reading the discussion there further, I have decided to go with @glaebhoerl's advice and ensure that we do not encounter undefined behavior due to the shift's RHS. This PR has now been updated accordingly, and is ready for review/merge. |
nikomatsakis
commented
Mar 20, 2015
nikomatsakis
commented
Mar 20, 2015
r+ -- This looks good to me. I had two questions though so not informing bors just yet (though no action is needed or requested necessarily). |
pnkfelix
commented
Mar 20, 2015
@nikomatsakis constant evaluation is not yet addressed. I don't know whether we have a reliable way to force the debug-assertions off, though that sounds like a good thing to have if we do not already have it. I will investigate. (Still, we probably can land this and leave those as to-do items. In particular, we need to deal with const-evaluation for every operation; not just shifts, and that still remains to be done.) |
pnkfelix
commented
Mar 21, 2015
bors
commented
Mar 21, 2015
⌛ Testing commit 61ff823 with merge c9798cb... |
bors
commented
Mar 21, 2015
💔 Test failed - auto-mac-64-opt |
pnkfelix
commented
Mar 21, 2015
odd, thought I had done a full test ... or no, maybe I only did |
pnkfelix
commented
Mar 21, 2015
(the bug I'm referring to in the commit is #20937 ) |
pnkfelix
commented
Mar 21, 2015
…atsakis overflow-checking for rhs of shift operators Subtask of rust-lang#22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
bors
commented
Mar 21, 2015
⌛ Testing commit 5e47c66 with merge 1c9b5a6... |
bors
commented
Mar 21, 2015
💔 Test failed - auto-mac-64-nopt-t |
bors
commented
Mar 23, 2015
💔 Test failed - auto-win-32-nopt-t |
pnkfelix
commented
Mar 23, 2015
hmm, I guess I need to pass Update: Oh, it also needs a 32-bit build. Hmm. |
pnkfelix
commented
Mar 23, 2015
@bors r=nikomatsakis bb9d210 |
1 similar comment
pnkfelix
commented
Mar 23, 2015
@bors r=nikomatsakis bb9d210 |
bors
commented
Mar 23, 2015
🙀 |
pnkfelix
commented
Mar 23, 2015
bors
commented
Mar 23, 2015
🙀 |
7623b75 to
bb9d210Comparepnkfelix
commented
Mar 23, 2015
@bors r=nikomatsakis bb9d210 |
pnkfelix
commented
Mar 23, 2015
@bors p=1 |
bors
commented
Mar 23, 2015
⌛ Testing commit bb9d210 with merge 9c638f8... |
bors
commented
Mar 23, 2015
⛄ The build was interrupted to prioritize another pull request. |
bors
commented
Mar 23, 2015
⌛ Testing commit bb9d210 with merge b93456c... |
bors
commented
Mar 23, 2015
⛄ The build was interrupted to prioritize another pull request. |
bors
commented
Mar 23, 2015
⌛ Testing commit bb9d210 with merge 28a0b25... |
overflow-checking for rhs of shift operators Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
overflow-checking for rhs of shift operators Subtask of rust-lang#22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
bors
commented
Mar 24, 2015
💔 Test failed - auto-win-32-nopt-t |
pnkfelix
commented
Mar 24, 2015
well, here's hoping the rollup suceeds where this latest merge attempt failed... |
pnkfelix
commented
Mar 24, 2015
@bors retry |
bors
commented
Mar 24, 2015
⚡ Previous build results for auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-nopt-t, auto-linux-64-opt, auto-linux-64-x-android-t, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-32-opt, auto-win-64-nopt-t, auto-win-64-opt are reusable. Rebuilding only auto-win-32-nopt-t... |
overflow-checking for rhs of shift operators
Subtask of #22020 (RFC 560)