[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-20 Thread gcc-bugs at marehr dot dialup.fu-berlin.de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #10 from gcc-bugs at marehr dot dialup.fu-berlin.de ---
Thank you!

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-20 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

Jonathan Wakely  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
   Target Milestone|--- |11.0

--- Comment #9 from Jonathan Wakely  ---
Fixed for 11.1

There should be a test to verify that __cpp_lib_to_chars is actually defined,
but that can be added later.

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #8 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
:

https://gcc.gnu.org/g:73ac2cfc69f466d082bf6fd68f10447575ae0612

commit r11-8261-g73ac2cfc69f466d082bf6fd68f10447575ae0612
Author: Jonathan Wakely 
Date:   Tue Apr 20 12:46:11 2021 +0100

libstdc++: Define __cpp_lib_to_chars for C++20 [PR 100146]

This defines the feature test macro when uselocale is available, because
the floating-point std::from_chars support currently depends on that.

Co-authored-by: Jakub Jelinek 

libstdc++-v3/ChangeLog:

PR libstdc++/100146
* include/std/charconv (__cpp_lib_to_chars): Define
conditionally.
* include/std/version (__cpp_lib_to_chars): Likewise..
* testsuite/20_util/from_chars/4.cc: Only check feature test
macro, not _GLIBCXX_HAVE_USELOCALE.
* testsuite/20_util/from_chars/5.cc: Likewise.
* testsuite/20_util/from_chars/6.cc: Likewise.
* testsuite/20_util/to_chars/long_double.cc: Likewise.

(cherry picked from commit f1a68574b1f8d2961d3a676dbcf0cc24b6368578)

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:f1a68574b1f8d2961d3a676dbcf0cc24b6368578

commit r12-6-gf1a68574b1f8d2961d3a676dbcf0cc24b6368578
Author: Jonathan Wakely 
Date:   Tue Apr 20 12:46:11 2021 +0100

libstdc++: Define __cpp_lib_to_chars for C++20 [PR 100146]

This defines the feature test macro when uselocale is available, because
the floating-point std::from_chars support currently depends on that.

Co-authored-by: Jakub Jelinek 

libstdc++-v3/ChangeLog:

PR libstdc++/100146
* include/std/charconv (__cpp_lib_to_chars): Define
conditionally.
* include/std/version (__cpp_lib_to_chars): Likewise..
* testsuite/20_util/from_chars/4.cc: Only check feature test
macro, not _GLIBCXX_HAVE_USELOCALE.
* testsuite/20_util/from_chars/5.cc: Likewise.
* testsuite/20_util/from_chars/6.cc: Likewise.
* testsuite/20_util/to_chars/long_double.cc: Likewise.

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #6 from Jonathan Wakely  ---
I suppose this would be OK:

#if _GLIBCXX_HAVE_USELOCALE
# define __cpp_lib_to_chars 201611L
#endif

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #5 from Jonathan Wakely  ---
It's std::from_chars which incorrectly allocates. It uses strtod which requires
a null-terminated string.

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #4 from Jakub Jelinek  ---
The uselocale thing could be handled by defining the macros only if
_GLIBCXX_HAVE_USELOCALE.  Does any implementation actually handle it without
memory allocations?  I mean, even sprintf can fail with ENOMEM if it needs to
allocate memory and looking at glibc __printf_fp_l, there are paths in which it
calls malloc as opposed to e.g. alloca.

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #3 from Jonathan Wakely  ---
No, because std::from_chars still depends on uselocale, and needs to allocate
memory (which can fail, yielding an error code that isn't permitted by the
standard).

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #2 from Jakub Jelinek  ---
Created attachment 50626
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50626=edit
gcc11-pr100146.patch

So do we want something like this patch then?

[Bug libstdc++/100146] __cpp_lib_to_chars not defined

2021-04-19 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||ppalka at gcc dot gnu.org,
   ||redi at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-04-19
 Ever confirmed|0   |1

--- Comment #1 from Jakub Jelinek  ---
charconv-// FIXME: Define when floating point is supported:
charconv:// #define __cpp_lib_to_chars 201611L
version:// #define __cpp_lib_to_chars 201611L
since r10-1020-gcd0b94e650a880b2ab04922e476aa28007277d5c (with adjustments).
But in
https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017
P0067R5 support is marked as completed.