[libc++][ranges] Fix the LWG 3568 test for basic_istream_view - #215589
Conversation
|
Hello @iskandarem 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
@llvm/pr-subscribers-libcxx Author: Iskandar Emomzoda (iskandarem) ChangesThe previous test was dereferencing This solution was suggested by @frederick-vs-ja in #193891, which verifies lwg3568 through constant evaluation. A This avoids dereferencing a past-the-end iterator while testing lwg 3568. Full diff: https://github.com/llvm/llvm-project/pull/215589.diff 1 Files Affected:
diff --git a/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp b/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp
index beeeea4c1bbe1..d15225674049c 100644
--- a/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.istream.view/ctor.pass.cpp
@@ -39,10 +39,8 @@ void test() {
// LWG 3568. basic_istream_view needs to initialize value_
{
- auto iss = make_string_stream<CharT>("");
- std::ranges::basic_istream_view<int, CharT> isv{iss};
- auto iter = isv.begin();
- assert(*iter == 0);
+ static auto fn_local_iss = make_string_stream<CharT>("");
+ [[maybe_unused]] constexpr auto isv = std::views::istream<int>(fn_local_iss);
}
}
|
confirmed. i have read the LLVM policies. |
basic_istream_view
|
I updated the title to be more in line with our practices. |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
frederick-vs-ja
left a comment
There was a problem hiding this comment.
I reworded the PR description to avoid tagging anybody and explained the modifications to the existing test case. Please double-check the changes.
We generally use the PR title and description as the squashed commit message by default. It will be disturbing if the squashed commit contains tagging and is replicated in some forks in GitHub since GitHub will send mail(s) when the replicated commit is pushed.
|
@iskandarem Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
The previous test was dereferencing
begin()iterator on empty view which is UB, becausebegin() == end().A new test case was suggested in a post-merge feedback in #193891, which verifies LWG3568 through constant evaluation. Such a
constexprbasic_istream_viewvariable can only be created if it is completely initialized, including its exposition-onlyvalue_member.The existing test case is changed to use a non-empty stream and a testing class type for which
operator>>is no-op. The state of the class object stored inbasic_istream_viewis unchanged even after the initialoperator>>call.This avoids dereferencing a past-the-end iterator while testing LWG3568.