Clear error_code on entry in win32_unicode_path constructor#3056
Open
ssam18 wants to merge 3 commits intoboostorg:developfrom
Open
Clear error_code on entry in win32_unicode_path constructor#3056ssam18 wants to merge 3 commits intoboostorg:developfrom
ssam18 wants to merge 3 commits intoboostorg:developfrom
Conversation
The win32_unicode_path constructor takes an error_code& parameter but
did not clear it on successful path conversion. This left callers with
stale error values even when the operation succeeded.
This is inconsistent with the std::filesystem convention where error_code
parameters are cleared on success (e.g., std::filesystem::create_directory).
It also caused unexpected behavior in file_win32::open() where a default
error_code value set before try/catch would persist even after successful
file operations.
This change adds 'ec = {};' at the beginning of the constructor to ensure
the error_code is always in a known state, either cleared for success or
set for failure.
Fixes boostorg#3035
Author
|
@vinniefalco - Can you please get a chance to review this PR? |
Collaborator
|
Please review all file-related operations to ensure they clear |
Address review feedback and ensured all file-related operations clear error_code on success.
libs/regex depends on libs/static_assert via Boost.Build, but it was missing from the Windows CI submodule checkout, causing all MSVC builds to fail with 'could not resolve project reference /boost/static_assert'.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3056 +/- ##
===========================================
- Coverage 93.18% 93.14% -0.04%
===========================================
Files 176 177 +1
Lines 13703 13706 +3
===========================================
- Hits 12769 12767 -2
- Misses 934 939 +5
... and 43 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.