Skip to content

Conversation

@StephanTLavavej
Copy link
Member

WG21-P2615R1 Meaningful Exports forbids extern "C++" from being directly applied to an explicit specialization. Now, every declaration is either a name-declaration or a special-declaration. An explicit-specialization is considered a special-declaration. But when directly applying extern "C++", the grammar for linkage-specialization requires that the extern string-literal name-declaration syntax cannot accept a special-declaration.

Clang 17 implemented P2615R1 as a DR in C++20 mode, but as of Clang 20 they don't enforce this rule (yet?). @xiangfan-ms brought this to my attention as he was implementing P2615R1 in MSVC.

The fix is simple: use extern "C++" { ... } scopes.

I am allowing the _Codecvt_guard helper to permanently remain in this scope, as it's not harmful, and I didn't think it was worth the effort to pull outside of the scope. (Indeed, right now the entire STL is marked with extern "C++" as a workaround.)

@StephanTLavavej StephanTLavavej requested a review from a team as a code owner February 5, 2026 12:34
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Feb 5, 2026
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Feb 5, 2026
@StephanTLavavej StephanTLavavej changed the title Use extern "C++" scopes for explicit specializations after P2615R1 Use extern "C++" scopes for explicit specializations after P2615R1 Meaningful Exports Feb 5, 2026
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews Feb 5, 2026
Copy link
Member

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

Simple change, LGTM

@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in STL Code Reviews Feb 5, 2026
@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Feb 9, 2026
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

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

Status: Merging

Development

Successfully merging this pull request may close these issues.

2 participants