Closed
Description
minimal example:
fn f(x: u64) -> u64 { x * 2 }
fn main() {
let g = f as i64;
println!("{}", g); // 94295280847184
}
Ordinarily rust is very strict about casts so I was surprised by this behavior when, because of a typo, I was trying to cast a fn
as an i64
. It compiled fine and resulted in garbage numbers that were difficult to track down. I assume this is a bug and not intended behavior.
First encountered the problem on nightly 1.27 2018-05-13 but it is also present in stable 1.26, per the playground example.