libstdc++: Fix std::format floating-point alternate forms [PR113512]
commita57439d61937925cec48df6166b2a805ae7054d5
authorJonathan Wakely <jwakely@redhat.com>
Sat, 20 Jan 2024 00:44:12 +0000 (20 00:44 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Sun, 21 Jan 2024 13:31:28 +0000 (21 13:31 +0000)
tree922370fc0d69e39a1444da53ac866e994d4fc824
parent29f931e39f2be86b454a8264b1cd42e4ca3cdcd7
libstdc++: Fix std::format floating-point alternate forms [PR113512]

The logic for handling '#' forms was ... not good. The count of
significant figures just counted digits, instead of ignoring leading
zeros. And when moving the result from the stack buffer to a dynamic
string the exponent could get lost in some cases.

libstdc++-v3/ChangeLog:

PR libstdc++/113512
* include/std/format (__formatter_fp::format): Fix logic for
alternate forms.
* testsuite/std/format/functions/format.cc: Check buggy cases of
alternate forms with g presentation type.
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc