Skip to content

Commit

Permalink
syserror.cpp: add more matches against std::errc::timed_out (microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
fsb4000 committed Aug 13, 2022
1 parent bac69e8 commit 2fb43a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stl/src/syserror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ namespace {
{ERROR_REPARSE_TAG_INVALID, errc::invalid_argument},
{ERROR_RETRY, errc::resource_unavailable_try_again},
{ERROR_SEEK, errc::io_error},
{ERROR_SEM_TIMEOUT, errc::timed_out},
{ERROR_SHARING_VIOLATION, errc::permission_denied},
{ERROR_TIMEOUT, errc::timed_out},
{ERROR_TOO_MANY_OPEN_FILES, errc::too_many_files_open},
{ERROR_WRITE_FAULT, errc::io_error},
{ERROR_WRITE_PROTECT, errc::permission_denied},
{WAIT_TIMEOUT, errc::timed_out},
{WSAEACCES, errc::permission_denied},
{WSAEADDRINUSE, errc::address_in_use},
{WSAEADDRNOTAVAIL, errc::address_not_available},
Expand Down
14 changes: 14 additions & 0 deletions tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ void test_lwg_3598() {
assert(error_code() == error_condition());
}

// Also test GH-2572: WAIT_TIMEOUT is not matched against by std::errc::timed_out
void test_gh_2572() {
assert((errc::timed_out == error_code{WAIT_TIMEOUT, system_category()}));
assert((make_error_condition(errc::timed_out) == error_code{WAIT_TIMEOUT, system_category()}));

assert((errc::timed_out == error_code{ERROR_TIMEOUT, system_category()}));
assert((make_error_condition(errc::timed_out) == error_code{ERROR_TIMEOUT, system_category()}));

assert((errc::timed_out == error_code{ERROR_SEM_TIMEOUT, system_category()}));
assert((make_error_condition(errc::timed_out) == error_code{ERROR_SEM_TIMEOUT, system_category()}));
}

int main() {
// Also test DevDiv-781294 "<system_error>: Visual C++ 2013 RC system_category().equivalent function does not work".
const error_code code(ERROR_NOT_ENOUGH_MEMORY, system_category());
Expand All @@ -57,6 +69,8 @@ int main() {
assert(!msg.empty() && msg.back() != '\0' && !isspace(static_cast<unsigned char>(msg.back())));

test_lwg_3598();

test_gh_2572();
}


Expand Down

0 comments on commit 2fb43a5

Please sign in to comment.