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

            Bug ID: 90299
           Summary: std::filesystem::absolute("") and
                    std::filesystem::absolute("", ec) behave differently
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ssh at pobox dot com
  Target Milestone: ---

Verified on GCC 8.x on macOS, Ubuntu and Wandbox HEAD
(https://wandbox.org/permlink/8OKSXauY3GpcfE8C):

#include <filesystem>
#include <iostream>

namespace fs = std::filesystem;

int main()
{
    std::error_code ec;
    std::cout << fs::absolute("", ec);
    std::cout << (ec ? " error" : " no error") << std::endl;
    std::cout << fs::absolute("");
}

Current result:

"" error
"/home/jail/"

For the given two calls:

std::filesystem::absolute("", ec)
std::filesystem::absolute("")

The first one returns an empty path and signals a ENOENT error while the second
one returns the usual POSIX current_path() / "". I think they should return the
same result (actually the non-error one) and I find nothing in the standard
suggesting different.

Additionally the note "Implementations are strongly encouraged to [...] not
consider !exists(p) an error" suggests that "not-found" is the one error that
nobody would expect.

Reply via email to