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

Don't deduce the return type of emplace{,_back,_front} #4963

Merged
merged 3 commits into from
Sep 19, 2024

Conversation

CaseyCarter
Copy link
Member

@CaseyCarter CaseyCarter commented Sep 17, 2024

The instantiation used to deduce the return types of template functions with placeholders in their declared return type happens outside the immediate context of any other template instantiation. Notably, that means the body of such an instantiation isn't an unevaluated context.

Switching to concrete return types will:

  1. Avoid return type deduction, correcting the problem described in DevCom-10745303, and
  2. Correct the ODR problem described in Potential ODR violation linking C++14 with C++17+ TUs that use container emplace functions #4962.

Fixes DevCom-10745303 / VSO-2252142 / AB#2252142

@CaseyCarter CaseyCarter added the bug Something isn't working label Sep 17, 2024
@CaseyCarter CaseyCarter requested a review from a team as a code owner September 17, 2024 23:47
The instantiation used to deduce the return types of template functions with placeholders in their declared return type happens outside the immediate context of any other template instantiation. Notably, that means the body of such an instantiation isn't an unevaluated context.

Fixes DevCom-10745303 / VSO-2252142
@StephanTLavavej StephanTLavavej self-assigned this Sep 19, 2024
@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 1e312b3 into microsoft:main Sep 19, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for emplacing this fix into the STL! 🪄 ⚙️ 😸

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.

Potential ODR violation linking C++14 with C++17+ TUs that use container emplace functions
3 participants