[Bug libstdc++/104870] [12 Regression] fast_float doesn't work for 16-bit size_t, but is used anyway by floating_from_chars.cc
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 10 21:41:08 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104870
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think we additionally want this:
--- a/libstdc++-v3/src/c++17/floating_from_chars.cc
+++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
@@ -793,12 +793,11 @@ from_chars_result
from_chars(const char* first, const char* last, float& value,
chars_format fmt) noexcept
{
-#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64
+#if USE_LIB_FAST_FLOAT
if (fmt == chars_format::hex)
return __floating_from_chars_hex(first, last, value);
else
{
- static_assert(USE_LIB_FAST_FLOAT);
return fast_float::from_chars(first, last, value, fmt);
}
#else
@@ -829,12 +828,11 @@ from_chars_result
from_chars(const char* first, const char* last, double& value,
chars_format fmt) noexcept
{
-#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64
+#if USE_LIB_FAST_FLOAT
if (fmt == chars_format::hex)
return __floating_from_chars_hex(first, last, value);
else
{
- static_assert(USE_LIB_FAST_FLOAT);
return fast_float::from_chars(first, last, value, fmt);
}
#else
@@ -865,8 +863,7 @@ from_chars_result
from_chars(const char* first, const char* last, long double& value,
chars_format fmt) noexcept
{
-#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \
- && ! USE_STRTOD_FOR_FROM_CHARS
+#if ! USE_STRTOD_FOR_FROM_CHARS
double dbl_value;
from_chars_result result;
if (fmt == chars_format::hex)
Otherwise we'll try to use fast_float again for a 16-bit target where uselocale
is available, when we should actually be using uselocale+strtod. But that
probably isn't a problem for AVR Libc right now, as it doesn't have uselocale.
For now I think we can just add the missing __SIZE_WIDTH_ >= 32 check.
More information about the Gcc-bugs
mailing list