-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Implement LWG3430 disallow implicit conversion of the source arguments to std::filesystem::path
when constructing std::basic_*fstream
#85079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
50656d0
[libc++] Implement LWG3430 std::fstream & co. should be constructible…
yronglin 5e995e9
[libc++] Refine test cases
yronglin 3090674
format
yronglin 0116f4a
Fix test
yronglin af85858
Fix test
yronglin 44b09c5
Refine code
yronglin 41aab57
Merge branch 'main' into LWG3430
yronglin eca5675
Address review comments and add release notes
yronglin 2babb84
Add period
yronglin fe70853
Update release notes
yronglin 79a0973
Update release notes
yronglin e59fcb2
Revert unnecessery changes
yronglin 8da6092
Revert unnecessery changes
yronglin bae96cf
Remove trailing whitespace
yronglin 917f988
Use TEST_HAS_OPEN_WITH_WCHAR replace _LIBCPP_HAS_OPEN_WITH_WCHAR
yronglin 1e073cd
Merge branch 'main' into LWG3430
yronglin aaad833
format
yronglin 616c732
Merge branch 'main' into LWG3430
yronglin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, https://en.cppreference.com/w/cpp/io/basic_fstream/basic_fstream mentions a
const std::filesystem::path::value_type*
overload which kinda happened to work before this change (since it'd construct a::path
and call that ctor), but this change breaks that. Should we undo this change here until an explicitconst std::filesystem::path::value_type*
ctor exists?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That constructor already exists:
llvm-project/libcxx/include/fstream
Lines 1413 to 1415 in a417b9b
It's definitely expected that you can't open an fstream with a
wstring
, the constructor taking afilesystem::path
should not be used to convert "anything string-like, with any character type, in any encoding" into a file name with implicit allocations and character conversions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want that conversion, you can still do it explicitly:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I suppose I need to call
c_str()
on my wstring to get the wchar_t ctor. Thanks, let me try that; sorry for the noise.(The point stands that this breaks existing code, though.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's indeed correct this may break existing code. Louis tested this at Apple, based on the results we applied the possibly breaking change. Is the breakage for you worse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it's just one file so far (). I got a bit confused because the wchar_t ctor is missing from the synopsis comment at the top. So all good.
*: But actually rolling this in is blocked on #86843 (comment) , so not 100% sure yet. But very likely that's all.