[llvm] [llvm][Support] ListeningSocket::accept returns operation_canceled if FD is set to -1 (PR #89479)

Connor Sughrue via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 19:54:39 PDT 2024


cpsughrue wrote:

Another important note. The code
```
  ASSERT_THAT_EXPECTED(MaybeServer, Failed());
  llvm::Error Err = MaybeServer.takeError();
  llvm::handleAllErrors(std::move(Err), [&](const llvm::StringError &SE) {
    std::error_code EC = SE.convertToErrorCode();
    ASSERT_EQ(EC, std::errc::timed_out);
  });
```
results in two instances of `MaybeServer.takeError()` which is problematic and was also causing issues. Comments in `Error.h` explain that after calling `takeError`, `Expected<T>` is in an indeterminate state that can only be safely destructed. The hidden `MaybeServer.takeError()` takes place during the evaluation of ASSERT_THAT_EXPECTED.

https://github.com/llvm/llvm-project/pull/89479


More information about the llvm-commits mailing list