Skip to content

<ranges>: Fix C2382 when mixing #include <ranges> with import std; - #6436

Closed
zika (tycket033-tech) wants to merge 2 commits into
microsoft:mainfrom
tycket033-tech:issue-6121-zip-sentinel-noexcept
Closed

zika (tycket033-tech) wants to merge 2 commits into
microsoft:mainfrom
tycket033-tech:issue-6121-zip-sentinel-noexcept

Conversation

@tycket033-tech

Copy link
Copy Markdown
Contributor

Fixes #6121

_Zip_iterator_sentinel_equal has a fold expression in its
noexcept-specifier. When a translation unit both #include <ranges>
and does import std;, the compiler fails to match the two declarations
as equivalent (C2382: redefinition; different exception specifications).

This extracts the fold expression into a variable template
_Zip_iterator_sentinel_equal_is_nothrow; both declarations then
reference a simple name + template arguments, which is trivially matched.

_Zip_iterator_sentinel_equal's noexcept-specifier contains a fold
expression, which the compiler fails to match as equivalent between the
textually-included and module-imported declarations, emitting C2382.
Extract it into a variable template so both declarations reference a
simple name, which is trivially matched.

Fixes microsoft#6121
Copilot AI balanced review requested due to automatic review settings September 4, 2026 18:12
@tycket033-tech
zika (tycket033-tech) requested a review from a team as a code owner September 4, 2026 18:12
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Sep 4, 2026
@azure-pipelines

This comment was marked as resolved.

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added bug Something isn't working ranges C++20/23 ranges modules C++23 modules, C++20 header units labels Sep 9, 2026
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) changed the title <ranges>: Fix C2382 when mixing #include <ranges> with import std; <ranges>: Fix C2382 when mixing #include <ranges> with import std; Sep 10, 2026
Comment thread stl/inc/ranges Resolved
Comment thread stl/inc/ranges Resolved
@github-project-automation github-project-automation Bot moved this from Initial Review to Work In Progress in STL Code Reviews Sep 24, 2026
…tes, cite DevCom-11148844 in TRANSITION comment
Copilot AI review requested due to automatic review settings September 25, 2026 03:05

This comment was marked as resolved.

@StephanTLavavej

Copy link
Copy Markdown
Member

Closing this workaround PR without merging as DevCom-11148844 (internal VSO-3061350) was fixed by internal MSVC-PR-780594 on 2026-09-14. (There's no point in merging a library workaround after the compiler has already been fixed.) This compiler fix will ship in the MSVC Build Tools 14.52 Preview very soon, and was merged just in time for 14.52 GA.

Thanks for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working modules C++23 modules, C++20 header units ranges C++20/23 ranges

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

<ranges>: _Zip_iterator_sentinel_equal redefinition error (C2382) when mixing #include <ranges> with import std;

3 participants