Ask questionsSpurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains

I'm unsure what the root cause of this is, and have been unable to reproduce it in a minimal project for many months, but every so often trig functions such as sin/cos/sin_cos will produce NaN values on perfectly valid inputs, only when using the Windows GNU toolchains.

In a project I have these lines:

let (sin_phi, cos_phi) = phi.sin_cos();

assert!(!sin_phi.is_nan(), "SIN {} {}", sin_phi, phi);
assert!(!cos_phi.is_nan(), "COS {} {}", cos_phi, phi);

which panics with this message:

thread 'main' panicked at 'SIN NaN -0.044661168'

on nightly-x86_64-pc-windows-gnu (1.40.0-nightly (3a9abe3f0 2019-10-15))

The program is complex but deterministic, and produces no such issues on the Windows MSVC toolchains.

This occurs with no RUSTFLAGS, and with the Cargo.toml config of:

debug = true
opt-level = 3
incremental = false
debug-assertions = true
codegen-units = 32

Answer questions mati865

Then it's the same as #53254 and I think there is no point in keeping it open.

This is (mostly?) packed_simd bug and should be fixed there, upstream tracking issue:


Related questions

using 'cargo install xsv' on windows 10 triggers rustc internal error hot 1
chain() make collect very slow hot 1
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
under latest MinGW, cannot link with C code using stdout hot 1
Archive all nightlies hot 1
Building LLVM with Clang fails hot 1
Internal compiler error: can't buffer lints after HIR lowering hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
Include images in rustdoc output hot 1
Some closures are not inlined in release mode hot 1
Github User Rank List