https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110133

--- 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:51f94778b45514992a716b0b2d7a87244e6f0018

commit r14-5123-g51f94778b45514992a716b0b2d7a87244e6f0018
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.

    We can use the recently-added std::string::__resize_and_overwrite to
    write directly into the string buffer when possible. Because we estimate
    the initial 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.

Reply via email to