Skip to content
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

Fix the interaction between _Pass_fn and invoke #1091

Merged
merged 2 commits into from
Jul 28, 2020

Conversation

CaseyCarter
Copy link
Member

@CaseyCarter CaseyCarter commented Jul 26, 2020

_Pass_fn returns a copy of arguments no larger than void*, and a call-forwarding reference-wrapper-alike _Ref_fn for larger function objects. This became a problem when Ranges started throwing pointers-to-member at _Pass_fn with the expectation that they would eventually be invoked: pointers-to-member can be larger than void*, but _Ref_fn doesn't speak the invoke protocol.

There are two relatively obvious possible fixes:

  1. Teach _Pass_fn to always return copies of pointers-to-member regardless of size
  2. Teach _Ref_fn to obey the invoke protocol

(1) results in "large" pointers-to-member that can't be enregistered being copied and passed by hidden reference resulting in larger codesize than (2), but with no corresponding performance benefits. We therefore implement (2) by teaching _Ref_fn to call-forward through invoke when it wraps a pointer-to-member.

Fixes GH-1089.

... to handle member-pointers that are larger than `void*` correctly.

Fixes microsoftGH-1089.
@CaseyCarter CaseyCarter added bug Something isn't working ranges C++20/23 ranges labels Jul 26, 2020
@CaseyCarter CaseyCarter requested a review from a team as a code owner July 26, 2020 04:29
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

Quantum cats! ⚛️ 🐱 Thanks, I think your solution is better than what I would have come up with.

@BillyONeal
Copy link
Member

It doesn't look like your title and message match the actual effects?

@CaseyCarter CaseyCarter changed the title Increase _Pass_fn's size threshold Fix the interaction between _Pass_fn and invoke Jul 27, 2020
@CaseyCarter
Copy link
Member Author

It doesn't look like your title and message match the actual effects?

Updated.

@CaseyCarter CaseyCarter self-assigned this Jul 28, 2020
@CaseyCarter CaseyCarter merged commit 35ce1cf into microsoft:master Jul 28, 2020
@CaseyCarter CaseyCarter deleted the gh-1089 branch July 28, 2020 22:34
@CaseyCarter
Copy link
Member Author

Thanks for fixing this bug that you should have noticed months ago!

@CaseyCarter CaseyCarter removed their assignment Jul 28, 2020
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.

<algorithm>: _Pass_fn/_Ref_fn interferes with the Ranges invoke protocol
3 participants