public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9879] libstdc++: Fix build for targets without FP std::from_chars [PR114633]
@ 2024-04-09 23:22 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2024-04-09 23:22 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:92b38ec84f2990d217f036dc6c5a32cde5ecfb93
commit r14-9879-g92b38ec84f2990d217f036dc6c5a32cde5ecfb93
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Apr 8 17:37:32 2024 +0100
libstdc++: Fix build for targets without FP std::from_chars [PR114633]
If the faster std::from_chars is not supported for floating-point types
then just extract the value from the stream using operator>>.
This fixes a build error for targets where __cpp_lib_to_chars is not
defined.
libstdc++-v3/ChangeLog:
PR libstdc++/114633
* include/bits/chrono_io.h (_Parser::operator()) <'S'>: Use
stream extraction if std::from_chars is not available.
Diff:
---
libstdc++-v3/include/bits/chrono_io.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h
index b9eb3d2be53..3b34992b42a 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -3685,6 +3685,7 @@ namespace __detail
if (!__is_failed(__err)) [[likely]]
{
long double __val{};
+#if __cpp_lib_to_chars
string __str = std::move(__buf).str();
auto __first = __str.data();
auto __last = __first + __str.size();
@@ -3694,6 +3695,9 @@ namespace __detail
if ((bool)ec || ptr != __last) [[unlikely]]
__err |= ios_base::failbit;
else
+#else
+ if (__buf >> __val)
+#endif
{
duration<long double> __fs(__val);
if constexpr (__is_floating)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-09 23:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 23:22 [gcc r14-9879] libstdc++: Fix build for targets without FP std::from_chars [PR114633] Jonathan Wakely
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).