aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-01-03 15:35:50 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-01-08 01:14:50 +0000
commit74a0dab18292bef54f316eb086112332befbc6a7 (patch)
tree71b10673a04967ef74bf90e9e711caf8815d50d3 /gcc
parentc97436f84cef191618f61912520bc0f0d62d8146 (diff)
downloadgcc-74a0dab18292bef54f316eb086112332befbc6a7.zip
gcc-74a0dab18292bef54f316eb086112332befbc6a7.tar.gz
gcc-74a0dab18292bef54f316eb086112332befbc6a7.tar.bz2
libstdc++: Implement P2909R4 ("Dude, where's my char?") for C++20
This change ensures that char and wchar_t arguments are formatted consistently when using integer presentation types. This avoids non-portable std::format output that depends on whether char and wchar_t happen to be signed or unsigned on the target. Formatting '\xff' as an integer will now always format 255 and not sometimes -1. This was approved in Kona 2023 as a DR for C++20 so the change is implemented unconditionally. Also make character formatters check for _Pres_c explicitly and call _M_format_character directly. This avoid the overhead of calling format and _S_to_character and then calling _M_format_character anyway. libstdc++-v3/ChangeLog: * include/bits/version.def (format_uchar): Define. * include/bits/version.h: Regenerate. * include/std/format (formatter<C, C>::format): Check for _Pres_c and call _M_format_character directly. Cast C to its unsigned equivalent for formatting as an integer. (formatter<char, wchar_t>::format): Likewise. (basic_format_arg(T&)): Store char arguments as unsigned char for formatting to a wide string. * testsuite/std/format/functions/format.cc: Adjust test. Check formatting of
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions