Skip to content

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains #65658

Closed
@novacrazy

Description

@novacrazy

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:

[profile.dev]
debug = true
opt-level = 3
incremental = false
debug-assertions = true
codegen-units = 32

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windows-gnuToolchain: GNU, Operating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions