Index: src/experimental/filesystem/operations.cpp =================================================================== --- src/experimental/filesystem/operations.cpp +++ src/experimental/filesystem/operations.cpp @@ -661,8 +661,9 @@ bool __remove(const path& p, std::error_code *ec) { if (ec) ec->clear(); + if (::remove(p.c_str()) == -1) { - set_or_throw(ec, "remove", p); + if (errno != ENOENT) set_or_throw(ec, "remove", p); return false; } return true; Index: test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp =================================================================== --- test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp +++ test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// class path + +#define _LIBCPP_DEBUG 0 +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++) +int AssertCount = 0; + +#include +#include +#include + +namespace fs = std::experimental::filesystem; + +int main() +{ + using namespace fs; + + path nFile("nonexistant.file"); + assert(remove(nFile) == false); + + path tempFilePath = temp_directory_path(); + tempFilePath += path("existingFile"); + + std::ofstream theTempFile(tempFilePath); + theTempFile.close(); + + assert(remove(tempFilePath) == true); + + return 0; +}