The linux man page for strerror says that some systems return NULL for
an unknown error number. That violates the C and POSIX standards, but we
can esily handle it to avoid a segfault.
libstdc++-v3/ChangeLog:
* src/c++11/system_error.cc (strerror_string): Handle
non-conforming NULL return from strerror.
#else
string strerror_string(int err)
{
- return strerror(err); // XXX Not thread-safe.
+ auto str = strerror(err); // XXX Not thread-safe.
+ if (str) [[__likely__]]
+ return str;
+ // strerror should not return NULL, but some implementations do.
+ return "Unknown error";
}
#endif