aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-02-10 16:10:46 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-09-23 16:07:39 +0100
commit477897451e46d67acb46f3ac45585e6eb9e7dde5 (patch)
treeeb482e7cf9d8251e5e00bbb6b901d99c4918d5d3 /gcc
parentdd396a321be5099536af36e64454c1fcf9d67e12 (diff)
downloadgcc-477897451e46d67acb46f3ac45585e6eb9e7dde5.zip
gcc-477897451e46d67acb46f3ac45585e6eb9e7dde5.tar.gz
gcc-477897451e46d67acb46f3ac45585e6eb9e7dde5.tar.bz2
libstdc++: Make std::system_category() recognize Windows error codes
The std::system_category error category should be used for system-specific error codes, which means on Windows it should be used for Windows error codes. Currently that category assumes that the error numbers it deals with are errno numbers, which means that ERROR_ACCESS_DENIED (which has value 0x5) gets treated as whichever errno number happens to have that value (EIO on mingw32-w64). This adds a mapping from known Windows error codes to generic errno ones. This means we correctly treat ERROR_ACCESS_DENIED as corresponding to EACCES. Also make std::system_category().message(int) return the right message for Windows errors, by using FormatMessage instead of strerror. The output of FormatMessage includes ".\r\n" at the end, so we strip that off to allow the message to be used in contexts where that would be problematic. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (system_error_category) [_WIN32]: Map Windows error codes to generic POSIX error numbers. Use FormatMessage instead of strerror. * testsuite/19_diagnostics/error_category/system_category.cc: Adjust for new behaviour on Windows.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions