https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110239
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:3bb9f9329c378934541ae4cff9977b7487e97cf0 commit r14-2105-g3bb9f9329c378934541ae4cff9977b7487e97cf0 Author: Jonathan Wakely <jwak...@redhat.com> Date: Mon Jun 26 14:46:46 2023 +0100 libstdc++: Fix std::format for pointers [PR110239] The formatter for pointers was casting to uint64_t which sign extends a 32-bit pointer and produces a value that won't fit in the provided buffer. Cast to uintptr_t instead. There was also a bug in the __parse_integer helper when converting a wide string to a narrow string in order to use std::from_chars on it. The function would always try to read 32 characters, even if the format string was shorter than that. Fix that bug, and remove the constexpr implementation of __parse_integer by just using __from_chars_alnum instead of from_chars, because that's usable in constexpr even in C++20. libstdc++-v3/ChangeLog: PR libstdc++/110239 * include/std/format (__format::__parse_integer): Fix buffer overflow for wide chars. (formatter<const void*, C>::format): Cast to uintptr_t instead of uint64_t. * testsuite/std/format/string.cc: Test too-large widths.