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.
This commit is contained in:
parent
02f03c5c82
commit
576f975cab
@ -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;
|
||||
|
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user