From 9dbe100a4157843d12b192e4aae504b43af4774b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 26 Oct 2016 12:29:36 +0100 Subject: [PATCH] PR78111 fix fallback code for filesystem::canonical PR libstdc++/78111 * src/filesystem/ops.cc (canonical): Set error for non-existent path. From-SVN: r241549 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/src/filesystem/ops.cc | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8287f7176ab..7d02cf4815f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2016-10-26 Jonathan Wakely + + PR libstdc++/78111 + * src/filesystem/ops.cc (canonical): Set error for non-existent path. + 2016-10-26 Uros Bizjak * acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Include diff --git a/libstdc++-v3/src/filesystem/ops.cc b/libstdc++-v3/src/filesystem/ops.cc index 32c9c5e850d..9abcee0ea9b 100644 --- a/libstdc++-v3/src/filesystem/ops.cc +++ b/libstdc++-v3/src/filesystem/ops.cc @@ -142,7 +142,11 @@ fs::canonical(const path& p, const path& base, error_code& ec) #endif if (!exists(pa, ec)) - return result; + { + if (!ec) + ec = make_error_code(std::errc::no_such_file_or_directory); + return result; + } // else: we know there are (currently) no unresolvable symlink loops result = pa.root_path();