https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126731
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Tomasz Kaminski <[email protected]>: https://gcc.gnu.org/g:9d7f5369bd888a1c62376db5065cea49007a7eb8 commit r16-9569-g9d7f5369bd888a1c62376db5065cea49007a7eb8 Author: Tomasz KamiÅski <[email protected]> Date: Thu Aug 13 09:51:56 2026 +0200 libstdc++: Format std::float16_t and std::bfloat16_t using respective std::to_chars overloads [PR126731] This patch removes the partial specialization for float16_t and bfloat16_t that formatted the values by casting to float. In consequence an implicit specialization of generic floating-point specialization is used, and to_chars overloads for their types are used. As explained in r13-3591-g0ae26533b3e268 (that adds corresponding to_chars overload), the shortest string (produced when no precision is specified) is shorter than float for above. As formatter specializations were defined under the same condition as corresponding to_chars overloads, the __formattable_float constrain on formatter floating-point specialization makes it enable in same cases. This reverted parts of r14-3305-g6cf214b4fc97f5 (revereted partially in r14-3329-g27d0cfcb2b33de), leading to (necessary for correctness) increase of the number template specializations. It also depends on preserving values of above types (instead of float) in basic_format_arg introduced r16-616-g9c9a7316adb996. The specializations for float32_t and float64_t are left unchanged, as their to_chars overloads are also implemented in terms of casting to float/double respectivelly. libstdc++-v3/ChangeLog: PR libstdc++/126731 * include/std/format (std::formatter<_Float16, _CharT>) (std::formatter<__format::__bflt16_t, _CharT>): Remove partial specializations. * testsuite/std/format/formatter/ext_float.cc: Test output for closest value to 1/10. Reviewed-by: Jonathan Wakely <[email protected]> Signed-off-by: Tomasz KamiÅski <[email protected]> (cherry picked from commit 4b6ce501c4f1db06c8084170a68796622266b671)
