[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-08 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

Jonathan Wakely  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #8 from Jonathan Wakely  ---
Since GCC 13 you can use _Float128 in older -std modes, and prior to GCC 13
there's no chance we're going to add this anyway.

The only thing missing here is that the _Float128 overloads are not declared
before C++23. They do exist in the library though, so if we declared them they
would be usable:

#include 

#if __cplusplus <= 202002L
namespace std
{
  from_chars_result
  from_chars(const char* __first, const char* __last, _Float128& __value,
 chars_format __fmt = chars_format::general) noexcept;

  to_chars_result
  to_chars(char* __first, char* __last, _Float128 __value) noexcept;
}
#endif

int main()
{
  char str[] = "0.5";
  _Float128 d = 2.0;
  std::to_chars(str, str+3, d);
  std::from_chars(str, str+3, d);
}

We could also add inline overloads for __float128 that forward to the _Float128
functions. The difficulty would be detecting when that's safe to do. We only
define the _Float128 overloads when that type is supported, and every time we
touch the macros around this something breaks.

Confirming as an enhancement, but I don't intent to work on this myself.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread g.peterhoff--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #7 from g.peterh...@t-online.de ---
Thank you. That was my question whether these two functions could be added.
At the moment I'm using boost.charconv https://github.com/cppalliance/charconv
https://develop.charconv.cpp.al (not official yet) - but it's still completely
buggy.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #6 from Andrew Pinski  ---
(In reply to g.peterhoff from comment #5)
> ??? I asked for std::from_chars/std::to_chars - which of course doesn't work:
> https://godbolt.org/z/n34dTajoc

std::from_chars/std::to_chars for extended floating point types is only
available with C++23 though. I really doubt they will be added for __float128 .
Maybe they could be enabled for pre-C++23 for the extended FP types too ..  But
a libstdc++ maintainer should answer that question since that would be an
extension.  Even having them for __float128 will be an extension too.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread g.peterhoff--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #5 from g.peterh...@t-online.de ---
??? I asked for std::from_chars/std::to_chars - which of course doesn't work:
https://godbolt.org/z/n34dTajoc

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #4 from Andrew Pinski  ---
_Float128 is supported in older c++ standards for gcc.  That is it does not
error out for -std=gnu++11 even.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread g.peterhoff--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #3 from g.peterh...@t-online.de ---
My problem is that I need from_chars/to_chars for __float128 also for older C++
standards that do not yet support _Float128/std::float128_t.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

Andrew Pinski  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2024-01-08
 Status|UNCONFIRMED |WAITING

--- Comment #2 from Andrew Pinski  ---
Actually it was added in GCC 13 by r13-3754-ge5bcbcd04cfcb2 .

Can you provide more information here what you need?

Using _Float128 is better than using __float128 since _Float128 is the C/C++
standard style of extended floating point types.

[Bug libstdc++/113260] missing from_chars/to_chars for __float128

2024-01-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113260

--- Comment #1 from Andrew Pinski  ---
There is support for _Float128 for from_chars/to_chars in GCC 14 already ..