summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/experimental/filesystem4
-rw-r--r--libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp4
2 files changed, 7 insertions, 1 deletions
diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem
index a667c739521..be7d23faee6 100644
--- a/libcxx/include/experimental/filesystem
+++ b/libcxx/include/experimental/filesystem
@@ -1393,7 +1393,9 @@ bool exists(const path& __p) {
inline _LIBCPP_INLINE_VISIBILITY
bool exists(const path& __p, error_code& __ec) _NOEXCEPT {
- return exists(__status(__p, &__ec));
+ auto __s = __status(__p, &__ec);
+ if (status_known(__s)) __ec.clear();
+ return exists(__s);
}
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
index 460b8be6b12..252ced6fd65 100644
--- a/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
@@ -65,6 +65,10 @@ TEST_CASE(test_exist_not_found)
{
const path p = StaticEnv::DNE;
TEST_CHECK(exists(p) == false);
+
+ std::error_code ec = GetTestEC();
+ TEST_CHECK(exists(p, ec) == false);
+ TEST_CHECK(!ec);
}
TEST_CASE(test_exists_fails)
OpenPOWER on IntegriCloud