public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position
@ 2022-12-10 11:12 hewillk at gmail dot com
2022-12-10 12:11 ` [Bug libstdc++/108046] " redi at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: hewillk at gmail dot com @ 2022-12-10 11:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
Bug ID: 108046
Summary: The dot in the floating-point alternative form has
wrong position
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
#include <format>
#include <iostream>
int main() {
std::cout << std::format("{:#.0}\n", 10.);
std::cout << std::format("{:#.1}\n", 10.);
std::cout << std::format("{:#.0g}\n", 10.);
}
libstdc++ gives:
1e+01.
1e+01.
1e+01
But they should all be "1.e+01"
https://godbolt.org/z/Y41ve6E7W
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
@ 2022-12-10 12:11 ` redi at gcc dot gnu.org
2023-04-26 6:57 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-12-10 12:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2022-12-10
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
2022-12-10 12:11 ` [Bug libstdc++/108046] " redi at gcc dot gnu.org
@ 2023-04-26 6:57 ` rguenth at gcc dot gnu.org
2023-07-27 9:24 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26 6:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.0 |13.2
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
2022-12-10 12:11 ` [Bug libstdc++/108046] " redi at gcc dot gnu.org
2023-04-26 6:57 ` rguenth at gcc dot gnu.org
@ 2023-07-27 9:24 ` rguenth at gcc dot gnu.org
2023-07-27 15:03 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27 9:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.2 |13.3
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
` (2 preceding siblings ...)
2023-07-27 9:24 ` rguenth at gcc dot gnu.org
@ 2023-07-27 15:03 ` cvs-commit at gcc dot gnu.org
2023-07-27 15:04 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-27 15:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
--- Comment #3 from CVS 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:50bc490c090cc95175e6068ed7438788d7fd7040
commit r14-2825-g50bc490c090cc95175e6068ed7438788d7fd7040
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jul 27 14:07:09 2023 +0100
libstdc++: Fix std::format alternate form for floating-point [PR108046]
A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.
This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.
For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.
This can be fixed by using __z == 0 when __prec == 0.
libstdc++-v3/ChangeLog:
PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
` (3 preceding siblings ...)
2023-07-27 15:03 ` cvs-commit at gcc dot gnu.org
@ 2023-07-27 15:04 ` redi at gcc dot gnu.org
2023-09-27 16:17 ` cvs-commit at gcc dot gnu.org
2023-09-27 16:19 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-27 15:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2022-12-10 00:00:00 |2023-07-27
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
` (4 preceding siblings ...)
2023-07-27 15:04 ` redi at gcc dot gnu.org
@ 2023-09-27 16:17 ` cvs-commit at gcc dot gnu.org
2023-09-27 16:19 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-27 16:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
--- Comment #5 from CVS 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:da1ba03245c212ef1ba100e7806588802f3ad46f
commit r13-7914-gda1ba03245c212ef1ba100e7806588802f3ad46f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jul 27 14:07:09 2023 +0100
libstdc++: Fix std::format alternate form for floating-point [PR108046]
A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.
This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.
For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.
This can be fixed by using __z == 0 when __prec == 0.
libstdc++-v3/ChangeLog:
PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.
(cherry picked from commit 50bc490c090cc95175e6068ed7438788d7fd7040)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
` (5 preceding siblings ...)
2023-09-27 16:17 ` cvs-commit at gcc dot gnu.org
@ 2023-09-27 16:19 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-09-27 16:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108046
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, thanks for the report.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-09-27 16:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-10 11:12 [Bug libstdc++/108046] New: The dot in the floating-point alternative form has wrong position hewillk at gmail dot com
2022-12-10 12:11 ` [Bug libstdc++/108046] " redi at gcc dot gnu.org
2023-04-26 6:57 ` rguenth at gcc dot gnu.org
2023-07-27 9:24 ` rguenth at gcc dot gnu.org
2023-07-27 15:03 ` cvs-commit at gcc dot gnu.org
2023-07-27 15:04 ` redi at gcc dot gnu.org
2023-09-27 16:17 ` cvs-commit at gcc dot gnu.org
2023-09-27 16:19 ` redi 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).