https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86597

            Bug ID: 86597
           Summary: directory_entry::exist et al forget to clear the
                    error_code.
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric at efcs dot ca
  Target Milestone: ---

The "file type observers" of directory entry like exists and is_regular_file
don't clear the error code they are given when no errors occurs.

Reproducer:

#include <filesystem>
#include <cassert>
using namespace std::filesystem;
using namespace std;

int main() {
    error_code ec = make_error_code(errc::address_in_use);
    directory_entry ent("/tmp");
    assert(ent.exists(ec));
    assert(!ec);
}

https://wandbox.org/permlink/TpQwW1VwBosGaHXZ

Reply via email to