public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's
@ 2024-04-26 7:49 lcarreon at bigpond dot net.au
2024-04-26 8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: lcarreon at bigpond dot net.au @ 2024-04-26 7:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
Bug ID: 114863
Summary: std::format applying grouping to nan's and inf's
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: lcarreon at bigpond dot net.au
Target Milestone: ---
The following code:
#include <locale>
#include <limits>
#include <iostream>
#include <format>
int main()
{
std::locale::global(std::locale{"en_AU.utf8"});
double values[] =
{
std::numeric_limits<double>::quiet_NaN(),
-std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::signaling_NaN(),
-std::numeric_limits<double>::signaling_NaN(),
std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity()
};
for (const auto& value : values)
{
std::cout << std::format("{0:Le} {0:Lf} {0:Lg}", value) << std::endl;
}
return 0;
}
Generates the following output:
nan nan nan
-,nan -,nan -,nan
nan nan nan
-,nan -,nan -,nan
inf inf inf
-,inf -,inf -,inf
Which in my opinion is incorrect because it applied thousands separator
grouping. Grouping should only be applied to finite values displayed in fixed
format.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
@ 2024-04-26 8:46 ` redi at gcc dot gnu.org
2024-04-26 10:06 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26 8:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Last reconfirmed| |2024-04-26
Status|UNCONFIRMED |ASSIGNED
Target Milestone|--- |13.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
2024-04-26 8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
@ 2024-04-26 10:06 ` redi at gcc dot gnu.org
2024-04-26 10:19 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26 10:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1734,7 +1734,7 @@ namespace __format
}
#endif
- if (_M_spec._M_localized)
+ if (_M_spec._M_localized && __builtin_isfinite(__v))
{
__wstr = _M_localize(__str, __expc, __fc.locale());
if (!__wstr.empty())
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
2024-04-26 8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
2024-04-26 10:06 ` redi at gcc dot gnu.org
@ 2024-04-26 10:19 ` redi at gcc dot gnu.org
2024-04-26 15:03 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-26 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Maybe we could also make _M_localize more efficient for finite values by not
even attempting to use grouping for scientific format.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
` (2 preceding siblings ...)
2024-04-26 10:19 ` redi at gcc dot gnu.org
@ 2024-04-26 15:03 ` cvs-commit at gcc dot gnu.org
2024-04-30 8:36 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-26 15:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #3 from GCC 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:a0bc71e480132a528a4869c1cd7863f709768c53
commit r15-5-ga0bc71e480132a528a4869c1cd7863f709768c53
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Apr 26 11:42:26 2024 +0100
libstdc++: Do not apply localized formatting to NaN and inf [PR114863]
We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.
libstdc++-v3/ChangeLog:
PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
` (3 preceding siblings ...)
2024-04-26 15:03 ` cvs-commit at gcc dot gnu.org
@ 2024-04-30 8:36 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:20 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-30 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:7a00c459cbb913ac165a39d344a48fc27800bb0a
commit r14-10154-g7a00c459cbb913ac165a39d344a48fc27800bb0a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Apr 26 11:42:26 2024 +0100
libstdc++: Do not apply localized formatting to NaN and inf [PR114863]
We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.
libstdc++-v3/ChangeLog:
PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.
(cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
` (4 preceding siblings ...)
2024-04-30 8:36 ` cvs-commit at gcc dot gnu.org
@ 2024-04-30 20:20 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:22 ` redi at gcc dot gnu.org
2024-05-01 5:37 ` lcarreon at bigpond dot net.au
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-30 20:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:61c38a231d2df60cb6e914b3ecc73a0229c17ff6
commit r13-8665-g61c38a231d2df60cb6e914b3ecc73a0229c17ff6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Apr 26 11:42:26 2024 +0100
libstdc++: Do not apply localized formatting to NaN and inf [PR114863]
We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.
libstdc++-v3/ChangeLog:
PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.
(cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
` (5 preceding siblings ...)
2024-04-30 20:20 ` cvs-commit at gcc dot gnu.org
@ 2024-04-30 20:22 ` redi at gcc dot gnu.org
2024-05-01 5:37 ` lcarreon at bigpond dot net.au
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-04-30 20:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 13.3 and 14.1, thanks for the report.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/114863] std::format applying grouping to nan's and inf's
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
` (6 preceding siblings ...)
2024-04-30 20:22 ` redi at gcc dot gnu.org
@ 2024-05-01 5:37 ` lcarreon at bigpond dot net.au
7 siblings, 0 replies; 9+ messages in thread
From: lcarreon at bigpond dot net.au @ 2024-05-01 5:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114863
--- Comment #7 from Leo Carreon <lcarreon at bigpond dot net.au> ---
I'm assuming the fix is for all floating point types not just double.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-05-01 5:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26 7:49 [Bug libstdc++/114863] New: std::format applying grouping to nan's and inf's lcarreon at bigpond dot net.au
2024-04-26 8:46 ` [Bug libstdc++/114863] " redi at gcc dot gnu.org
2024-04-26 10:06 ` redi at gcc dot gnu.org
2024-04-26 10:19 ` redi at gcc dot gnu.org
2024-04-26 15:03 ` cvs-commit at gcc dot gnu.org
2024-04-30 8:36 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:20 ` cvs-commit at gcc dot gnu.org
2024-04-30 20:22 ` redi at gcc dot gnu.org
2024-05-01 5:37 ` lcarreon at bigpond dot net.au
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).