-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
bitwise operation takes wrong value #11580
Comments
This doesn't appear to be a problem anymore, can it be closed? |
This still reproduces for me when compiling with optimizations. |
fn main() {
let m : [u8, ..1] = [ 0u8 ];
println!("{}", ((m[0] >> 8) | 0) as u16);
println!("{}", ((m[0] >> 8) | m[0]) as u16);
assert!((((m[0] >> 8) | 0) as u16) == 0);
assert!((((m[0] >> 8) | m[0]) as u16) == 255);
}
|
Bit shifts with a RHS equal to or larger than the width of the type in bytes have undefined behaviour in C and LLVM. The code here is shifting an 8-bit integer by 8 bits. This issue is reported as #10183 already. |
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Oct 6, 2023
[`manual_let_else`]: only omit block if span is from same ctxt Fixes rust-lang#11579. The lint already had logic for omitting a block in `else` if a block is already present, however this didn't handle the case where the block is from a different expansion/syntax context. E.g. ```rs macro_rules! panic_in_block { () => { { panic!() } } } let _ = match Some(1) { Some(v) => v, _ => panic_in_block!() }; ``` It would see this in its expanded form as `_ => { panic!() }` and think it doesn't have to include a block in its suggestion because it is already there, however that's not true if it's from a different expansion like in this case. changelog: [`manual_let_else`]: only omit block in suggestion if the block is from the same expansion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm on caf316a
Found a strange value calculation when bitwising with wrong casting:
https://gist.github.com/ya-mouse/8444726
The text was updated successfully, but these errors were encountered: