[PATCH][risc-v] libstdc++: Preserve signbit of nan when converting float to double [PR113578]
Jonathan Wakely
jwakely@redhat.com
Tue May 7 13:49:33 GMT 2024
Do we want this change for RISC-V, to fix PR113578?
I haven't tested it on RISC-V, only on x86_64-linux (where it doesn't do
anything).
-- >8 --
libstdc++-v3/ChangeLog:
PR libstdc++/113578
* include/std/ostream (operator<<(basic_ostream&, float)):
Restore signbit after converting to double.
---
libstdc++-v3/include/std/ostream | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 8a21758d0a3..d492168ca0e 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -233,7 +233,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 117. basic_ostream uses nonexistent num_put member functions.
+#ifdef __riscv
+ return _M_insert(__builtin_copysign((double)__f,
+ (double)-__builtin_signbit(__f));
+#else
return _M_insert(static_cast<double>(__f));
+#endif
}
__ostream_type&
--
2.44.0
More information about the Libstdc++
mailing list