`<filesystem>`: `exists` returns true for `[file-path]/.`
Open
Nobody has claimed this yet.
bug
filesystem
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
I suspect that in the following code, exists("test/.") should return false, as the path should refer to directory only.
(I haven't looked into the standard, but gcc and clangs reports assertion failure, and cppreference says v.)
#include<fstream>
#include<filesystem>
#include<cassert>
int main()
{
using namespace std::filesystem;
std::ofstream("test") << "test";
// As expected:
assert(exists("test"));
assert(is_regular_file("test"));
assert(!exists("test/"));
// But what about these? (Currently they will pass the assertion...)
assert(exists("test/."));
assert(is_regular_file("test/."));
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided C++ reproducer and verify the standard’s expected behavior for paths ending in /.. Trace the std::filesystem::exists and is_regular_file entry points, then compare their results with the expected directory-only semantics. Done means the behavior is resolved and the shown case has regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100