Miri 将 2.0f64.powi(63) 计算为 2^63 − 2048,而不是精确的 2^63,从而导致了 float_to_int_unchecked UB
作者: Roticv912创建于 2026年9月18日更新于 2026年9月19日
A under miri —— no UB reported: half bits = 0x43dffffffffffffe, exact = 9223372036854773760 out = 18446744073709547520 EXIT=0 # A under rustc (native) —— exact value: half bits = 0x43e0000000000000, exact = 9223372036854775808 out = 9223372036854775808 EXIT=0 # B under miri —— UB reported: error: Undefined Behavior: float_to_int_unchecked intrinsic called on 1.8446744073709552E+19f64 which cannot be represented in target type u64 EXIT=1
内容来源: rust-lang/miri