When running this code:
fn main() {
const NUMBER: u64 = 0b_10101010;
fn print_shift(i: u32) {
println!("{:b}", NUMBER >> i);
}
print_shift(65);
println!("{:b}", NUMBER >> 65);
}
You see that shifting the bits of a number with a value longer than the bit length causes a different behavior when executed at compile time or at run time.
Is this normal behavior? Is this documented somewhere? This is not on the list of documented behavior undefined .
source
share