Skip to content

Conversation

@AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented Nov 30, 2025

Fix regression in #5808.

We can't move out lvalue reference.

The optimization for lvalue references is still possible, but we have to handle this case slightly differently.
Now, if the function is passed as lvalue, we copy from the passed function. instead of moving it out.


Other cases of lvalue reference in call unwrapping:

  • Inner move_only_function: [func.wrap.move.ctor]/6 and the definition of move_only_function enforces that attempt to use lvalue reference here won't compile. So no handling is needed.
  • Inner copyable_function: will need to handle lvalue reference with this approach applied in one more place, in addition to these three places
  • Inner function_ref. There can be lvalue references. But I don't know if we want to nullify moved-out function_ref or not. More natural would be to leave moved out function_ref intact, so we will always do as if we have lvalue reference.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Dec 1, 2025
@StephanTLavavej StephanTLavavej self-assigned this Dec 1, 2025
@StephanTLavavej StephanTLavavej removed their assignment Dec 1, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Dec 1, 2025
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Dec 1, 2025
@StephanTLavavej StephanTLavavej merged commit e36f2f1 into microsoft:main Dec 1, 2025
45 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Dec 1, 2025
@StephanTLavavej
Copy link
Member

Thanks for noticing and fixing this! 🏠 💥 🏚️ 🛠️ 🏡

@AlexGuteniev AlexGuteniev deleted the whoops branch December 1, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants