Clear error_code on entry in win32_unicode_path constructor #3056
+1
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3035
Issue
The
win32_unicode_pathconstructor accepts anerror_code¶meter but wasn't clearing it on successful path conversion. This led to callers retaining stale error values even when operations succeeded.Problem
As reported in #3035, when using
file.open()with a pre-set error code (e.g., initialized toerror::not_foundas a default), the error would persist even after successful file operations. This is inconsistent with std::filesystem conventions where error_code parameters are cleared on success.Solution
Added
ec = {};at the beginning of the constructor to ensure the error_code is always in a known state - either cleared for success or properly set for failure.This aligns with:
std::filesystem::create_directory)ecimmediately upon entry to avoid these kinds of issuesfile_win32::openwhich already clears ec on line 222Testing
Windows-specific change. The fix is minimal and follows established error handling patterns in the codebase.