[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #8 from Jonathan Wakely --- Author: redi Date: Thu May 16 23:09:51 2019 New Revision: 271302 URL: https://gcc.gnu.org/viewcvs?rev=271302=gcc=rev Log: PR libstdc++/90299 make filesystem::absolute overloads consistent In this implementation it is an error to pass the empty path to absolute, because the empty path doesn't represent any file in the filesystem so the function cannot meet its postcondition. Currently the absolute(const path&, error_code&) overload reports an error for the empty path, but using errc::no_such_file_or_directory, and the other overload does not report an error. This patch makes them consistntly report an errc::invalid_argument error for the empty path. Backport from mainline 2019-05-04 Jonathan Wakely PR libstdc++/90299 * src/filesystem/std-ops.cc (absolute(const path&)): Report an error if the argument is an empty path. (absolute(const path&, error_code&)): Use invalid_argument as error code instead of no_such_file_or_directory. * testsuite/27_io/filesystem/operations/absolute.cc: Check handling of non-existent paths and empty paths with both overloads of absolute. Modified: branches/gcc-8-branch/libstdc++-v3/ChangeLog branches/gcc-8-branch/libstdc++-v3/src/filesystem/std-ops.cc branches/gcc-8-branch/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 Jonathan Wakely changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |8.4 --- Comment #9 from Jonathan Wakely --- Fixed for GCC 8.4 and 9.2
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #7 from Jonathan Wakely --- Author: redi Date: Thu May 16 23:00:26 2019 New Revision: 271301 URL: https://gcc.gnu.org/viewcvs?rev=271301=gcc=rev Log: PR libstdc++/90299 make filesystem::absolute overloads consistent In this implementation it is an error to pass the empty path to absolute, because the empty path doesn't represent any file in the filesystem so the function cannot meet its postcondition. Currently the absolute(const path&, error_code&) overload reports an error for the empty path, but using errc::no_such_file_or_directory, and the other overload does not report an error. This patch makes them consistntly report an errc::invalid_argument error for the empty path. Backport from mainline 2019-05-04 Jonathan Wakely PR libstdc++/90299 * src/c++17/fs_ops.cc (absolute(const path&)): Report an error if the argument is an empty path. (absolute(const path&, error_code&)): Use invalid_argument as error code instead of no_such_file_or_directory. * testsuite/27_io/filesystem/operations/absolute.cc: Check handling of non-existent paths and empty paths with both overloads of absolute. Backport from mainline 2019-05-16 Jonathan Wakely * src/c++17/fs_ops.cc (absolute(const path&, error_code&)) [_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Remove bogus assertion. Modified: branches/gcc-9-branch/libstdc++-v3/ChangeLog branches/gcc-9-branch/libstdc++-v3/src/c++17/fs_ops.cc branches/gcc-9-branch/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #6 from Jonathan Wakely --- Fixed on trunk so far.
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #5 from Jonathan Wakely --- Author: redi Date: Sat May 4 14:35:33 2019 New Revision: 270874 URL: https://gcc.gnu.org/viewcvs?rev=270874=gcc=rev Log: PR libstdc++/90299 make filesystem::absolute overloads consistent In this implementation it is an error to pass the empty path to absolute, because the empty path doesn't represent any file in the filesystem so the function cannot meet its postcondition. Currently the absolute(const path&, error_code&) overload reports an error for the empty path, but using errc::no_such_file_or_directory, and the other overload does not report an error. This patch makes them consistntly report an errc::invalid_argument error for the empty path. PR libstdc++/90299 * src/c++17/fs_ops.cc (absolute(const path&)): Report an error if the argument is an empty path. (absolute(const path&, error_code&)): Use invalid_argument as error code instead of no_such_file_or_directory. * testsuite/27_io/filesystem/operations/absolute.cc: Check handling of non-existent paths and empty paths with both overloads of absolute. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/src/c++17/fs_ops.cc trunk/libstdc++-v3/testsuite/27_io/filesystem/operations/absolute.cc
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #4 from Jonathan Wakely --- Although that suggests I should report the error as errc::invalid_argument not errc::no_such_file_or_directory.
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #3 from Jonathan Wakely --- And for the avoidance of doubt, the problem is not that !exists(p) (although that is true) but that an empty path doesn't refer to any file system location. absolute("does not exist") is not an error, but absolute("") is. There is no absolute representation of the empty path, it's a category error.
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 --- Comment #2 from Jonathan Wakely --- I changed absolute("", ec) to return an error intentionally, and I think absolute("") should also return an error. The effects of the function are to "compose an absolute path referencing the same file system location as p". When p is the empty path it does not reference any file system location, and so the function cannot meet its postcondition, and must report an error. The bug is that r260441 only fixed the overload taking an error_code& parameter.
[Bug libstdc++/90299] std::filesystem::absolute("") and std::filesystem::absolute("", ec) behave differently
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90299 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2019-05-02 Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely --- (In reply to Steffen Schuemann from comment #0) > 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. I like to keep users on their toes ;-)