Closed
Description
Here is some strange code uncovered by a test I wrote for #23536:
fn id<T>(x: T) -> T { x }
fn main() {
let spot: Option<i8>;
let x = 1_i8 << id(8_i8);
spot = Some(x);
assert_eq!(spot.unwrap(), 0);
println!("so we stored a zero byte ... but:");
assert_eq!(x, 0);
}
Even in the playpen, this prints:
so we stored a zero byte ... but:
thread '<main>' panicked at 'assertion failed: `(left == right) && (right == left)` (left: `0`, right: `0`)', <anon>:9
playpen: application terminated with error code 101
Note those "crazy, non-matching" left and right values.
(Presumably something with LLVM's low-level code is leaving x
in a register, thus yielding hidden high-order bits after the shift is done; those need to be masked away before we attempt to compare with another register.)
Metadata
Metadata
Assignees
Labels
No labels