public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
@ 2022-04-21  1:40 nishida_kenji at nintendo dot co.jp
  2022-04-21  9:24 ` [Bug c++/105324] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: nishida_kenji at nintendo dot co.jp @ 2022-04-21  1:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105324
           Summary: std::from_chars() assertion at
                    floating_from_chars.cc:78 when parsing 1.11111111....
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nishida_kenji at nintendo dot co.jp
  Target Milestone: ---

CODE:
--------
#include <memory>
#include <charconv>
#include <cstring>
#include <cstdio>

int main() {
#ifdef __GLIBCXX__
    std::printf("GLIBCXX: %d\n",__GLIBCXX__);
#endif
    std::unique_ptr<char[]> mem(new char[1024 * 128]);
    std::memset(mem.get(), '1', 10000);
    mem[1]     = '.';
    mem[511] = '\0';
    double val;
    std::from_chars(mem.get(), mem.get() + 511, val);
    std::printf("511: %f\n", val);

    std::memset(mem.get(), '1', 10000);
    mem[1]     = '.';
    mem[512] = '\0';
    std::from_chars(mem.get(), mem.get() + 512, val);
    std::printf("512: %f\n", val);
    return 0;
}
---
RESULT:
GLIBCXX: 20220127
511: 1.111111
../../../../../libstdc++-v3/src/c++17/floating_from_chars.cc:78: virtual void*
std::{anonymous}::buffer_resource::do_allocate(std::size_t, std::size_t):
Assertion 'alignment != 1' failed.

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
@ 2022-04-21  9:24 ` redi at gcc dot gnu.org
  2022-04-21 10:34 ` cvs-commit at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-21  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2022-04-21
      Known to fail|                            |11.3.0
   Target Milestone|---                         |11.4
      Known to work|                            |12.0
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Kenji Nishida from comment #0)
> #ifdef __GLIBCXX__
>     std::printf("GLIBCXX: %d\n",__GLIBCXX__);

N.B. this macro is not useful for this purpose:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning.__GLIBCXX__

That's not relevant to the bug though, which I can confirm.

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
  2022-04-21  9:24 ` [Bug c++/105324] " redi at gcc dot gnu.org
@ 2022-04-21 10:34 ` cvs-commit at gcc dot gnu.org
  2022-04-21 12:34 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 10:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:cf37107522f465d9e12af01ba68d2d1df0f18d46

commit r12-8213-gcf37107522f465d9e12af01ba68d2d1df0f18d46
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Apr 21 11:26:49 2022 +0100

    libstdc++: Remove bogus assertion in std::from_chars [PR105324]

    I'm not sure what I was thinking when I added this assertion, maybe it
    was supposed to be alignment == 1 (which is what the pmr::string actually
    uses). The simplest fix is to just remove the assertion.

    The assertion is no longer enabled by default on trunk, but it's still
    there for the --enablke-libstdcxx-debug build, and is still wrong. The
    fix is needed on the gcc-11 branch.

    libstdc++-v3/ChangeLog:

            PR libstdc++/105324
            * src/c++17/floating_from_chars.cc (buffer_resource::do_allocate):
            Remove assertion.
            * testsuite/20_util/from_chars/pr105324.cc: New test.

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
  2022-04-21  9:24 ` [Bug c++/105324] " redi at gcc dot gnu.org
  2022-04-21 10:34 ` cvs-commit at gcc dot gnu.org
@ 2022-04-21 12:34 ` cvs-commit at gcc dot gnu.org
  2022-04-21 12:38 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-21 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:d26c3e4f733fcb07d90680491dd1d7a9d08c4705

commit r11-9920-gd26c3e4f733fcb07d90680491dd1d7a9d08c4705
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Apr 21 11:26:49 2022 +0100

    libstdc++: Remove bogus assertion in std::from_chars [PR105324]

    I'm not sure what I was thinking when I added this assertion, maybe it
    was supposed to be alignment == 1 (which is what the pmr::string actually
    uses). The simplest fix is to just remove the assertion.

    The assertion is no longer enabled by default on trunk, but it's still
    there for the --enablke-libstdcxx-debug build, and is still wrong. The
    fix is needed on the gcc-11 branch.

    libstdc++-v3/ChangeLog:

            PR libstdc++/105324
            * src/c++17/floating_from_chars.cc (buffer_resource::do_allocate):
            Remove assertion.
            * testsuite/20_util/from_chars/pr105324.cc: New test.

    (cherry picked from commit cf37107522f465d9e12af01ba68d2d1df0f18d46)

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (2 preceding siblings ...)
  2022-04-21 12:34 ` cvs-commit at gcc dot gnu.org
@ 2022-04-21 12:38 ` redi at gcc dot gnu.org
  2022-05-02 21:43 ` aoliva at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-21 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 11.4

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (3 preceding siblings ...)
  2022-04-21 12:38 ` redi at gcc dot gnu.org
@ 2022-05-02 21:43 ` aoliva at gcc dot gnu.org
  2022-05-02 21:53 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2022-05-02 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |aoliva at gcc dot gnu.org
         Resolution|FIXED                       |---

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
The from_chars overloads for floating-point types are guarded by #if
_GLIBCXX_HAVE_USELOCALE

The test fails with ugly overload resolution and template substitution messages
over the template from_chars for integral types when the macro is not defined
to nonzero.

Should the test use a similar conditional?  (I'll be happy to submit a patch)

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (4 preceding siblings ...)
  2022-05-02 21:43 ` aoliva at gcc dot gnu.org
@ 2022-05-02 21:53 ` redi at gcc dot gnu.org
  2022-05-03 17:58 ` [Bug libstdc++/105324] " 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 @ 2022-05-02 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It should depend on:
#if __cpp_lib_to_chars >= 201611L

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

* [Bug libstdc++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (5 preceding siblings ...)
  2022-05-02 21:53 ` redi at gcc dot gnu.org
@ 2022-05-03 17:58 ` cvs-commit at gcc dot gnu.org
  2022-05-06 10:27 ` 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 @ 2022-05-03 17:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:25389f3de489c25a6983db96428a6bf06aedc829

commit r13-87-g25389f3de489c25a6983db96428a6bf06aedc829
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue May 3 14:57:15 2022 -0300

    [PR105324] libstdc++: testsuite: pr105324 requires FP from_char

    The floating-point overloads of from_char are only declared if
    _GLIBCXX_HAVE_USELOCALE is #defined as nonzero.  That's exposed from
    charconv as __cpp_lib_to_chars >= 201611L, so guard the test body with
    that.


    for  libstdc++-v3/ChangeLog

            PR c++/105324
            * testsuite/20_util/from_chars/pr105324.cc: Guard test body
            with conditional for floating-point overloads of from_char.

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

* [Bug libstdc++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (6 preceding siblings ...)
  2022-05-03 17:58 ` [Bug libstdc++/105324] " cvs-commit at gcc dot gnu.org
@ 2022-05-06 10:27 ` cvs-commit at gcc dot gnu.org
  2022-05-06 10:34 ` cvs-commit at gcc dot gnu.org
  2022-05-06 10:37 ` [Bug c++/105324] " aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-06 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Alexandre Oliva
<aoliva@gcc.gnu.org>:

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

commit r12-8347-ge8cd7d0066e0ba2a082b0e7de35e883837546583
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri May 6 07:26:04 2022 -0300

    [PR105324] libstdc++: testsuite: pr105324 requires FP from_char

    The floating-point overloads of from_char are only declared if
    _GLIBCXX_HAVE_USELOCALE is #defined as nonzero.  That's exposed from
    charconv as __cpp_lib_to_chars >= 201611L, so guard the test body with
    that.


    for  libstdc++-v3/ChangeLog

            PR c++/105324
            * testsuite/20_util/from_chars/pr105324.cc: Guard test body
            with conditional for floating-point overloads of from_char.

    (cherry picked from commit 25389f3de489c25a6983db96428a6bf06aedc829)

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

* [Bug libstdc++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (7 preceding siblings ...)
  2022-05-06 10:27 ` cvs-commit at gcc dot gnu.org
@ 2022-05-06 10:34 ` cvs-commit at gcc dot gnu.org
  2022-05-06 10:37 ` [Bug c++/105324] " aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-06 10:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Alexandre Oliva
<aoliva@gcc.gnu.org>:

https://gcc.gnu.org/g:799ff8e3e38f62632a98f8931ca291d191e677d5

commit r11-9960-g799ff8e3e38f62632a98f8931ca291d191e677d5
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri May 6 07:33:50 2022 -0300

    [PR105324] libstdc++: testsuite: pr105324 requires FP from_char

    The floating-point overloads of from_char are only declared if
    _GLIBCXX_HAVE_USELOCALE is #defined as nonzero.  That's exposed from
    charconv as __cpp_lib_to_chars >= 201611L, so guard the test body with
    that.


    for  libstdc++-v3/ChangeLog

            PR c++/105324
            * testsuite/20_util/from_chars/pr105324.cc: Guard test body
            with conditional for floating-point overloads of from_char.

    (cherry picked from commit 25389f3de489c25a6983db96428a6bf06aedc829)

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

* [Bug c++/105324] std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111....
  2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
                   ` (8 preceding siblings ...)
  2022-05-06 10:34 ` cvs-commit at gcc dot gnu.org
@ 2022-05-06 10:37 ` aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2022-05-06 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
          Component|libstdc++                   |c++
         Resolution|---                         |FIXED

--- Comment #10 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Testcase adjustments are all in.

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

end of thread, other threads:[~2022-05-06 10:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21  1:40 [Bug c++/105324] New: std::from_chars() assertion at floating_from_chars.cc:78 when parsing 1.11111111 nishida_kenji at nintendo dot co.jp
2022-04-21  9:24 ` [Bug c++/105324] " redi at gcc dot gnu.org
2022-04-21 10:34 ` cvs-commit at gcc dot gnu.org
2022-04-21 12:34 ` cvs-commit at gcc dot gnu.org
2022-04-21 12:38 ` redi at gcc dot gnu.org
2022-05-02 21:43 ` aoliva at gcc dot gnu.org
2022-05-02 21:53 ` redi at gcc dot gnu.org
2022-05-03 17:58 ` [Bug libstdc++/105324] " cvs-commit at gcc dot gnu.org
2022-05-06 10:27 ` cvs-commit at gcc dot gnu.org
2022-05-06 10:34 ` cvs-commit at gcc dot gnu.org
2022-05-06 10:37 ` [Bug c++/105324] " aoliva at gcc dot gnu.org

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