Fix issue of missing sign in binary_float_op when result of rem is zero#109573
Fix issue of missing sign in binary_float_op when result of rem is zero#109573chenyukang wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
|
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
There was a problem hiding this comment.
I don't think this is the proper place to fix this. l % r should already give you the right result. There is likely something wrong in the rustc_apfloat crate, probably here, though I don't really understand how soft float works
rust/compiler/rustc_apfloat/src/ieee.rs
Lines 1003 to 1017 in f421586
There was a problem hiding this comment.
yes, you're right, I didn't notice use rustc_apfloat::Float.
I think we may have a similar fix at here? I updated the code.
tests/ui/mir/issue-109567.rs
Outdated
There was a problem hiding this comment.
What part of the compiler are you specifically trying to test here?
If you're updating const eval, maybe it would make sense to add a test for this in https://github.com/rust-lang/rust/tree/master/tests/mir-opt/const_prop?
There was a problem hiding this comment.
The new fix don't change mir part, so I moved the test case to tests/ui/numbers-arithmetic/.
345cdba to
965a05d
Compare
1336670 to
dacbb8d
Compare
dacbb8d to
99f7fb0
Compare
There was a problem hiding this comment.
This does nothing. Making a const fn just means the function can be called from a const, but you are not doing that, and then it is a total NOP.
What I meant is something like
const G: f64 = -1.0 % -1.0;Then you also don't need the feature gate.
There was a problem hiding this comment.
Fixed it.
According to #109573 (comment), it's not suggested to make changes to this file? 🤔
abd8a4d to
eb59b9c
Compare
|
Yeah, Rust's apfloat port has been in licensing limbo for years, meaning we have no idea how to even go about fixing bugs in it. :( |
|
If we can't change apfloat, I suggest that @chenyukang revert to the original patch of doing the check in |
|
Not sure I agree -- littering the surrounding code with checks to patch the results sounds pretty bad. FWIW this is not the only bugfix that is blocked on apfloat. We really need to figure out the apfloat situations, and solve it properly. |
|
seems we are blocking at this PR: #96784 |
|
I posted a longer update to #55993 (comment) regarding the progress with the whole |
|
Hi @chenyukang, thanks for the fix! As @eddyb mentioned, this has been fixed in the new version of the Thanks again for your efforts! 🙂 |
Fixes #109567