]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::format("{:F}", inf) to use uppercase
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 12:02:27 +0000 (13:02 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 17 Aug 2023 12:12:39 +0000 (13:12 +0100)
commitd07bce478f9d770de5acb0480a3f0cec2f8b72d8
tree6770aee86653d1ffe2d94dfc66d8b7e0569fa611
parentb10dfbb54efb7f5ed48eaa11c79f112a85676f24
libstdc++: Fix std::format("{:F}", inf) to use uppercase

std::format was treating {:f} and {:F} identically on the basis that for
the fixed 1.234567 format there are no alphabetical characters that need
to be in uppercase. But that's wrong for infinities and NaNs, which
should be formatted as "INF" and "NAN" for {:F}.

libstdc++-v3/ChangeLog:

* include/std/format (__format::_Pres_type): Add _Pres_F.
(__formatter_fp::parse): Use _Pres_F for 'F'.
(__formatter_fp::format): Set __upper for _Pres_F.
* testsuite/std/format/functions/format.cc: Check formatting of
infinity and NaN for each presentation type.
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc