From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, Patrick Palka <ppalka@redhat.com>
Subject: [PATCH 1/2] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441]
Date: Sun, 1 May 2022 14:21:08 -0400 [thread overview]
Message-ID: <20220501182109.3668200-1-ppalka@redhat.com> (raw)
The hexfloat parser for binary32/64 added in r12-6645-gcc3bf3404e4b1c
overlooked that the exponent part can also begin with an uppercase 'P'.
Tested on x86_64-pc-linux-gnu, does this look OK for trunk/11, and possibly the
12 branch now for 12.1?
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.
---
libstdc++-v3/src/c++17/floating_from_chars.cc | 2 +-
libstdc++-v3/testsuite/20_util/from_chars/7.cc | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc
index 13de1e346ab..e7f3a58cf18 100644
--- a/libstdc++-v3/src/c++17/floating_from_chars.cc
+++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
@@ -664,7 +664,7 @@ namespace
// Parse the written exponent.
int written_exponent = 0;
- if (first != last && *first == 'p')
+ if (first != last && (*first == 'p' || *first == 'P'))
{
// Tentatively consume the 'p' and try to parse a decimal number.
const char* const fallback_first = first;
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/7.cc b/libstdc++-v3/testsuite/20_util/from_chars/7.cc
index 2a78c7441e2..1aa9b230531 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/7.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/7.cc
@@ -96,6 +96,7 @@ constexpr testcase testcases[] = {
{ "1p-1", 4, {}, 0x1p-1 },
{ "0", 1, {}, 0.0 },
{ "A", 1, {}, 0xA },
+ { "1.ABCDEFP+10", 12, {}, 0x1.ABCDEFP+10 },
{ "-1", 2, {}, -1.0 },
{ "-0", 2, {}, -0.0 },
{ "42", 2, {}, 0x42p0 },
--
2.36.0.44.g0f828332d5
next reply other threads:[~2022-05-01 18:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 18:21 Patrick Palka [this message]
2022-05-01 18:21 ` [PATCH 2/2] libstdc++: Don't use std::tolower in <charconv> [PR103911] Patrick Palka
2022-05-01 19:07 ` Jonathan Wakely
2022-05-01 19:09 ` [PATCH 1/2] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441] Jonathan Wakely
2022-05-02 5:05 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220501182109.3668200-1-ppalka@redhat.com \
--to=ppalka@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).