Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cpplearner
Copy link
Contributor

@cpplearner cpplearner commented Jul 20, 2022

Fixes #2889

Casey's drive-by: Give up on the Standard's dream that we can avoid defining projected::operator*. There are just too many interactions with the "need for constant evaluation" rules and the use of types with internal linkage - it's not worth fighting anymore.

@cpplearner cpplearner requested a review from a team as a code owner July 20, 2022 08:25
Copy link
Contributor

@miscco miscco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing some additional test coverage.

strega-nil-ms
strega-nil-ms previously approved these changes Jul 20, 2022
@StephanTLavavej StephanTLavavej added bug Something isn't working ranges C++20/23 ranges labels Jul 20, 2022
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing my approval as I do not believe it correctly implements the standard.

@strega-nil-ms strega-nil-ms dismissed their stale review July 21, 2022 17:02

change in opinion

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely took a bit to convince me that this is correct, but I have now been convinced.

Copy link
Contributor

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestions, of which we have enough that I think I should push changes.

@CaseyCarter CaseyCarter removed their assignment Aug 4, 2022
#else // ^^^ no workaround / workaround vvv
indirect_result_t<_Proj&, _It> operator*() const {
_CSTD abort(); // TRANSITION, VSO-1308657
_CSTD abort();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers:

projected is a tool to simplify expressing the requirements of algorithms that use projections. The design intent is that the member functions don't have definitions - they are just signatures that exist for iter_reference_t et al. to look at. This hasn't worked well in practice in the real world, as witnessed by the warning suppressions for clang and MSVC around the definition, the additional bug report (VSO-1308657) mentioned there, and the fact that it broke yet again when I made Bool a local class in that PR. The PR uses projected<Bool*, identity>, and clang-cl decided to report an error about operator* being used-but-not-defined when it can't possibly be defined in another TU since Bool has internal linkage. Rather than trying to find yet another workaround for this perennial issue (four or five changes here in ~3 years?) I decided to give up and simply always define operator* to call abort. The function should never be called in practice, so even if it does end up emitted into some object files the linker should be able to clean it up.

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sad about projected::operator*, but cools.

@StephanTLavavej StephanTLavavej self-assigned this Aug 5, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 9ed0e6b into microsoft:main Aug 5, 2022
@StephanTLavavej
Copy link
Member

Thanks for fixing this compiler error and improving the ranges experience! 😻 🐞 🎉

@cpplearner cpplearner deleted the patch-1 branch August 6, 2022 03:26
strega-nil pushed a commit to strega-nil/stl that referenced this pull request Aug 6, 2022
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ranges C++20/23 ranges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<ranges>: chunk_by_view's helper lambda does not specify return type

8 participants