https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110133
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:ca233ac9ba085e2acd385bda6a778684a0c96694 commit r13-8129-gca233ac9ba085e2acd385bda6a778684a0c96694 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri Nov 3 13:59:48 2023 +0000 libstdc++: Use strerror_r in std::generic_category()::message(int) [PR110133] Use strerror_r instead of strerror when available, due to the latter not being thread-safe. This is complicated by Glibc providing a GNU-specific strerror_r which is not compatible with POSIX strerror_r, so we need to dispatch on the return type. Because we estimate the initial std::string buffer size we might end up with excess capacity in the returned std::string. We can slightly tweak the std::system_error constructors to make use of that excess capacity, so that in some cases we require fewer allocations to construct the std::system_error::what() string. libstdc++-v3/ChangeLog: PR libstdc++/110133 * include/std/system_error (system_error::system_error): Group arguments so that concatenation can reuse rvalue's capacity. * src/c++11/system_error.cc (strerror_string): New function. [_GLIBCXX_HAVE_STRERROR_R] (use_strerror_result): New functions. (generic_error_category::message): Use strerror_string. (system_error_category::message): Likewise. (cherry picked from commit 51f94778b45514992a716b0b2d7a87244e6f0018)