[PATCH] D20903: Make system_error::message() thread safe. Fixes PR25598.

Erik Kessler via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 16:29:45 PDT 2016


erik65536 added a subscriber: erik65536.
erik65536 added a comment.

The C++ spec states that `error_category::message()` shall not change the value of `errno` (See section 19.5). So `errno` will have to be saved and restored if `strerror_r()` fails.

The POSIX version of `strerror_r()` returns 0 on success, and any other value indicates an error (Reference <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html>).

The function may return uninitialized memory if `std::snprintf()` fails.

You may want to a version for Windows that calls `strerror_s()`.


http://reviews.llvm.org/D20903





More information about the cfe-commits mailing list