On x86 (32bit) targets, returning a floating-point number from a "C" ABI function by-value can change the bits of their NaN payloads. (Specifically, the quiet bit gets set.) This is caused by using x87 registers to pass return values, as mandated by the ABI for this target; this requires a format conversion, and that conversion quiets NaNs. For targets that require SSE2, we have patched the "Rust" ABI to avoid this problem; x86-32 targets where SSE2 is optional have the same problem for "Rust" functions as well.
This is a known and long-standing problem, and very hard to fix. The purpose of this issue mostly is to document its existence and to give it a URL that can be referenced.
A proper fix would require patching LLVM to use different code to load float return values into an x87 register -- specifically, it has to be done in a way that NaN payloads are fully preserved. It would be lovely if we could find someone who both cares enough about x86-32 to make sure it correctly implements the Rust semantics and who has the expertise to write the LLVM patch this requires. :)
Related issues:
Prior issues:
On x86 (32bit) targets, returning a floating-point number from a "C" ABI function by-value can change the bits of their NaN payloads. (Specifically, the quiet bit gets set.) This is caused by using x87 registers to pass return values, as mandated by the ABI for this target; this requires a format conversion, and that conversion quiets NaNs. For targets that require SSE2, we have patched the "Rust" ABI to avoid this problem; x86-32 targets where SSE2 is optional have the same problem for "Rust" functions as well.
This is a known and long-standing problem, and very hard to fix. The purpose of this issue mostly is to document its existence and to give it a URL that can be referenced.
A proper fix would require patching LLVM to use different code to load float return values into an x87 register -- specifically, it has to be done in a way that NaN payloads are fully preserved. It would be lovely if we could find someone who both cares enough about x86-32 to make sure it correctly implements the Rust semantics and who has the expertise to write the LLVM patch this requires. :)
Related issues:
Prior issues: