-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Two consecutive std::f32::sin() invocations on the same value give different results in certain scenarios #109118
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I noticed that, in certain scenarios, two consecutive
std::f32::sin()function invocations can give two different results.A scenario where I observed this is the following:
When the
opt-levelis set to 1, the assert fails with the following output:When the
opt-levelis 0, both outputs are3f2fc6ea, and when it is 2 or 3 both outputs are3f2fc6e9.Another surprising thing for me is that when I remove the last println (
println!("{a}");), the assert passes even foropt-level=1. In that case, values are3f2fc6eaonly when theopt-levelis 0, while for other values they are3f2fc6e9.Meta
rustc --version --verbose:This also occurs on the following nightly version: