Skip to content

Use extern "C++" scopes for explicit specializations after P2615R1 Meaningful Exports - #6074

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:extern-specializations
Feb 11, 2026
Merged

Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:extern-specializations

Conversation

@StephanTLavavej

Copy link
Copy Markdown
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?). Xiang Fan (@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 Stephan T. Lavavej (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 Stephan T. Lavavej (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 Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Final Review in STL Code Reviews Feb 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Simple change, LGTM

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Final Review to Ready To Merge in STL Code Reviews Feb 5, 2026
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Feb 9, 2026
@StephanTLavavej

Copy link
Copy Markdown
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.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit b352c2c into microsoft:main Feb 11, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Feb 11, 2026
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) deleted the extern-specializations branch February 11, 2026 13:41
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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants