public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH][risc-v] libstdc++: Preserve signbit of nan when converting float to double [PR113578]
Date: Tue,  7 May 2024 14:49:33 +0100	[thread overview]
Message-ID: <20240507135019.3821031-1-jwakely@redhat.com> (raw)

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


             reply	other threads:[~2024-05-07 13:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07 13:49 Jonathan Wakely [this message]
2024-05-07 13:57 ` Jeff Law
2024-05-07 14:06   ` Jonathan Wakely
2024-05-07 14:11     ` Jonathan Wakely
2024-05-07 16:24       ` Palmer Dabbelt
2024-05-10 10:58       ` Jonathan Wakely
2024-05-07 15:25     ` Jeff Law
2024-05-07 15:36 ` Andreas Schwab
2024-05-07 16:31   ` Jeff Law
2024-05-07 16:39     ` Jonathan Wakely
2024-05-07 16:45       ` Jonathan Wakely
2024-05-08 10:32         ` Andrew Waterman
2024-05-08 10:40           ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240507135019.3821031-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).