public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format
@ 2022-04-30 16:24 hewillk at gmail dot com
  2022-04-30 17:35 ` [Bug libstdc++/105441] " hewillk at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hewillk at gmail dot com @ 2022-04-30 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105441
           Summary: The floating point overload of from_chars ignores 'P'
                    for hex format
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

>From StackOverflow
https://stackoverflow.com/questions/72068948/is-stdfrom-chars-supposed-to-handle-uppercase-hexadecimal-exponents/72069971#72069971

testsuite:
https://godbolt.org/z/ad1es7eE6

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

* [Bug libstdc++/105441] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
@ 2022-04-30 17:35 ` hewillk at gmail dot com
  2022-04-30 17:36 ` hewillk at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hewillk at gmail dot com @ 2022-04-30 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
floating_from_chars.cc#L667

// Parse the written exponent.
int written_exponent = 0;
if (first != last && *first == 'p')
  {
    // Tentatively consume the 'p' and try to parse a decimal number.
    const char* const fallback_first = first;

it seems like it should be

if (first != last && std::tolower((unsigned char)*first) == 'p')

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

* [Bug libstdc++/105441] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
  2022-04-30 17:35 ` [Bug libstdc++/105441] " hewillk at gmail dot com
@ 2022-04-30 17:36 ` hewillk at gmail dot com
  2022-04-30 17:50 ` [Bug libstdc++/105441] [12/13 Regression] " ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hewillk at gmail dot com @ 2022-04-30 17:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
floating_from_chars.cc#L667

// Parse the written exponent.
int written_exponent = 0;
if (first != last && *first == 'p')
  {
    // Tentatively consume the 'p' and try to parse a decimal number.
    const char* const fallback_first = first;

it seems like it should be

if (first != last && std::tolower((unsigned char)*first) == 'p')

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

* [Bug libstdc++/105441] [12/13 Regression] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
  2022-04-30 17:35 ` [Bug libstdc++/105441] " hewillk at gmail dot com
  2022-04-30 17:36 ` hewillk at gmail dot com
@ 2022-04-30 17:50 ` ppalka at gcc dot gnu.org
  2022-05-02 11:03 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-30 17:50 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
   Last reconfirmed|                            |2022-04-30
   Target Milestone|---                         |12.0
      Known to fail|                            |12.0, 13.0
            Summary|The floating point overload |[12/13 Regression] The
                   |of from_chars ignores 'P'   |floating point overload of
                   |for hex format              |from_chars ignores 'P' for
                   |                            |hex format

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for reporting and analyzing this!

(In reply to 康桓瑋 from comment #2)
> floating_from_chars.cc#L667
> 
> // Parse the written exponent.
> int written_exponent = 0;
> if (first != last && *first == 'p')
>   {
>     // Tentatively consume the 'p' and try to parse a decimal number.
>     const char* const fallback_first = first;
> 
> it seems like it should be
> 
> if (first != last && std::tolower((unsigned char)*first) == 'p')

I'm not sure we can use tolower here because it's locale dependent and charconv
isn't.  So we should just test for 'p' and 'P' directly.  And we should
probably replace the existing use of tolower in find_end_of_float.

I wonder why the SO user is seeing this bug with GCC 11.2?  The new hexfloat
parser (r12-6645-gcc3bf3404e4b1c) is GCC 12 only.

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

* [Bug libstdc++/105441] [12/13 Regression] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2022-04-30 17:50 ` [Bug libstdc++/105441] [12/13 Regression] " ppalka at gcc dot gnu.org
@ 2022-05-02 11:03 ` cvs-commit at gcc dot gnu.org
  2022-05-02 11:44 ` cvs-commit at gcc dot gnu.org
  2022-05-03 13:23 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-02 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:576f975cabb0fd9843de152a2d247d486a967b08

commit r13-69-g576f975cabb0fd9843de152a2d247d486a967b08
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon May 2 07:00:48 2022 -0400

    libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441]

    The hexfloat parser for binary32/64 added in r12-6645-gcc3bf3404e4b1c
    overlooked that the exponent part can also begin with an uppercase 'P'.

            PR libstdc++/105441

    libstdc++-v3/ChangeLog:

            * src/c++17/floating_from_chars.cc (__floating_from_chars_hex):
            Also accept 'P' as the start of the exponent.
            * testsuite/20_util/from_chars/7.cc: Add corresponding testcase.

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

* [Bug libstdc++/105441] [12/13 Regression] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2022-05-02 11:03 ` cvs-commit at gcc dot gnu.org
@ 2022-05-02 11:44 ` cvs-commit at gcc dot gnu.org
  2022-05-03 13:23 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-02 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:4a6d7da796e456115bbac92e056123f095a3780c

commit r12-8327-g4a6d7da796e456115bbac92e056123f095a3780c
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon May 2 07:00:48 2022 -0400

    libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441]

    The hexfloat parser for binary32/64 added in r12-6645-gcc3bf3404e4b1c
    overlooked that the exponent part can also begin with an uppercase 'P'.

            PR libstdc++/105441

    libstdc++-v3/ChangeLog:

            * src/c++17/floating_from_chars.cc (__floating_from_chars_hex):
            Also accept 'P' as the start of the exponent.
            * testsuite/20_util/from_chars/7.cc: Add corresponding testcase.

    (cherry picked from commit 576f975cabb0fd9843de152a2d247d486a967b08)

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

* [Bug libstdc++/105441] [12/13 Regression] The floating point overload of from_chars ignores 'P' for hex format
  2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2022-05-02 11:44 ` cvs-commit at gcc dot gnu.org
@ 2022-05-03 13:23 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-03 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

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

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Should be fixed.

Replacing the use of std::tolower was done in the subsequent commit
r13-70-g86d821ddf5615e.

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

end of thread, other threads:[~2022-05-03 13:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-30 16:24 [Bug libstdc++/105441] New: The floating point overload of from_chars ignores 'P' for hex format hewillk at gmail dot com
2022-04-30 17:35 ` [Bug libstdc++/105441] " hewillk at gmail dot com
2022-04-30 17:36 ` hewillk at gmail dot com
2022-04-30 17:50 ` [Bug libstdc++/105441] [12/13 Regression] " ppalka at gcc dot gnu.org
2022-05-02 11:03 ` cvs-commit at gcc dot gnu.org
2022-05-02 11:44 ` cvs-commit at gcc dot gnu.org
2022-05-03 13:23 ` ppalka 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).