Closed
Description
pub fn f() -> f64 {
std::hint::black_box(-1.0) % std::hint::black_box(-1.0)
}
pub fn g() -> f64 {
-1.0 % -1.0
}
pub fn main() {
println!("with black box: {}", f());
println!("without black box: {}", g());
assert_eq!(f().signum(), g().signum());
}
% rustc repro.rs && ./repro
with black box: -0
without black box: 0
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `-1.0`,
right: `1.0`', repro.rs:12:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Not sure whether -1.0 % -1.0
should be 0
or -0
according to IEEE 754, but codegen (with black box) and const eval (without blackbox) should produce the same result
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (1459b3128 2023-03-23)
binary: rustc
commit-hash: 1459b3128e288a85fcc4dd1fee7ada2cdcf28794
commit-date: 2023-03-23
host: aarch64-apple-darwin
release: 1.70.0-nightly
LLVM version: 15.0.7