public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8327] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441]
@ 2022-05-02 11:44 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-05-02 11:44 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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)

Diff:
---
 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 },


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-02 11:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 11:44 [gcc r12-8327] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441] Patrick Palka

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