public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined
@ 2021-04-19  9:42 gcc-bugs at marehr dot dialup.fu-berlin.de
  2021-04-19  9:58 ` [Bug libstdc++/100146] " jakub at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gcc-bugs at marehr dot dialup.fu-berlin.de @ 2021-04-19  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

            Bug ID: 100146
           Summary: __cpp_lib_to_chars not defined
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

Hi gcc-team,

it seems that you implemented the float variants of <charconv> in gcc-11.

Is there a reason that you did not define `__cpp_lib_to_chars`?

The following code:

```cpp
#include <version>

#ifndef __cpp_lib_to_chars
#warning("__cpp_lib_to_chars NOT defined")
#endif

#include <charconv>

#ifndef __cpp_lib_to_chars
#warning("__cpp_lib_to_chars NOT defined")
#endif

#include <string_view>

int main()
{
    float value;
    std::string_view view{"5.55"};

    std::from_chars(view.begin(), view.end(), value);
}
```

throws warnings.

https://godbolt.org/z/WK7qs84Th

Thank you!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
@ 2021-04-19  9:58 ` jakub at gcc dot gnu.org
  2021-04-19 10:24 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-19  9:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

Jakub Jelinek <jakub at gcc dot gnu.org> 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 <jakub at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
  2021-04-19  9:58 ` [Bug libstdc++/100146] " jakub at gcc dot gnu.org
@ 2021-04-19 10:24 ` jakub at gcc dot gnu.org
  2021-04-19 10:36 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-19 10:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

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

So do we want something like this patch then?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
  2021-04-19  9:58 ` [Bug libstdc++/100146] " jakub at gcc dot gnu.org
  2021-04-19 10:24 ` jakub at gcc dot gnu.org
@ 2021-04-19 10:36 ` redi at gcc dot gnu.org
  2021-04-19 11:01 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 10:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (2 preceding siblings ...)
  2021-04-19 10:36 ` redi at gcc dot gnu.org
@ 2021-04-19 11:01 ` jakub at gcc dot gnu.org
  2021-04-19 11:15 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-19 11:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (3 preceding siblings ...)
  2021-04-19 11:01 ` jakub at gcc dot gnu.org
@ 2021-04-19 11:15 ` redi at gcc dot gnu.org
  2021-04-19 11:19 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 11:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's std::from_chars which incorrectly allocates. It uses strtod which requires
a null-terminated string.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (4 preceding siblings ...)
  2021-04-19 11:15 ` redi at gcc dot gnu.org
@ 2021-04-19 11:19 ` redi at gcc dot gnu.org
  2021-04-20 11:51 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I suppose this would be OK:

#if _GLIBCXX_HAVE_USELOCALE
# define __cpp_lib_to_chars 201611L
#endif

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (5 preceding siblings ...)
  2021-04-19 11:19 ` redi at gcc dot gnu.org
@ 2021-04-20 11:51 ` cvs-commit at gcc dot gnu.org
  2021-04-20 11:54 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 11:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

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

commit r12-6-gf1a68574b1f8d2961d3a676dbcf0cc24b6368578
Author: Jonathan Wakely <jwakely@redhat.com>
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 <jakub@redhat.com>

    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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (6 preceding siblings ...)
  2021-04-20 11:51 ` cvs-commit at gcc dot gnu.org
@ 2021-04-20 11:54 ` cvs-commit at gcc dot gnu.org
  2021-04-20 11:55 ` redi at gcc dot gnu.org
  2021-04-20 12:01 ` gcc-bugs at marehr dot dialup.fu-berlin.de
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 11:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

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

commit r11-8261-g73ac2cfc69f466d082bf6fd68f10447575ae0612
Author: Jonathan Wakely <jwakely@redhat.com>
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 <jakub@redhat.com>

    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)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (7 preceding siblings ...)
  2021-04-20 11:54 ` cvs-commit at gcc dot gnu.org
@ 2021-04-20 11:55 ` redi at gcc dot gnu.org
  2021-04-20 12:01 ` gcc-bugs at marehr dot dialup.fu-berlin.de
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-20 11:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100146

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |11.0

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/100146] __cpp_lib_to_chars not defined
  2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (8 preceding siblings ...)
  2021-04-20 11:55 ` redi at gcc dot gnu.org
@ 2021-04-20 12:01 ` gcc-bugs at marehr dot dialup.fu-berlin.de
  9 siblings, 0 replies; 11+ messages in thread
From: gcc-bugs at marehr dot dialup.fu-berlin.de @ 2021-04-20 12:01 UTC (permalink / raw)
  To: 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!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-20 12:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19  9:42 [Bug libstdc++/100146] New: __cpp_lib_to_chars not defined gcc-bugs at marehr dot dialup.fu-berlin.de
2021-04-19  9:58 ` [Bug libstdc++/100146] " jakub at gcc dot gnu.org
2021-04-19 10:24 ` jakub at gcc dot gnu.org
2021-04-19 10:36 ` redi at gcc dot gnu.org
2021-04-19 11:01 ` jakub at gcc dot gnu.org
2021-04-19 11:15 ` redi at gcc dot gnu.org
2021-04-19 11:19 ` redi at gcc dot gnu.org
2021-04-20 11:51 ` cvs-commit at gcc dot gnu.org
2021-04-20 11:54 ` cvs-commit at gcc dot gnu.org
2021-04-20 11:55 ` redi at gcc dot gnu.org
2021-04-20 12:01 ` gcc-bugs at marehr dot dialup.fu-berlin.de

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).