`<filesystem>`: MSVC's `path` conversion from wide to narrow throws an exception (`fs::path(L"要").string()`)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Describe the bug
MSVC's std::filesystem::path conversion from wide to narrows crashing with the following snippet:
#include <iostream>
#include <filesystem>
int main() {
std::filesystem::path(L"要らない.exe").string();
std::cout << "Hello World!\n";
}
I also tried in a fresh sandbox with fresh latest VS Community installation and crash is happening on both builds x86|x64 Debug|Release:
Microsoft C++ exception: std::system_error at memory location
Also tried compiling with and without unicode enabled. Same behavior.
Expected behavior
conversion should succeed and not crash the program.
STL version
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.11.1
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 by reproducing the failure with the provided std::filesystem::path(L"要らない.exe").string() snippet on Visual Studio 2022 17.11.1 across the reported configurations. Trace the wide-to-narrow path conversion and verify that the conversion completes without throwing and the program reaches the Hello World output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100