Incorrect operation after bit shift with negative left hand side expression.
lukyxu opened this issue · 1 comments
lukyxu commented
fn main() {
let b = -5_i128 >> 2;
println!("{}", b);
let c = b * 3;
println !("{}", c)
}
Expected output:
-2
-6
Actual output:
-2
6
There are similar errors when replacing the shift left operator with shift right and/or replacing the multiply operator with the division operator. Interestingly, printing both b and c afterwards println !("{} {}", b, c) results in the correct output.
thepowersgang commented
Oops, a typo in sign handling of i128
multiplication in the C backend.
Not present in the constant evaluator, which is why it works if the print is done after the calculation.