Skip to content

Workaround for MSVC modules bug#1560

Draft
YexuanXiao wants to merge 2 commits into
microsoft:masterfrom
YexuanXiao:msvc-11070187-upstream
Draft

Workaround for MSVC modules bug#1560
YexuanXiao wants to merge 2 commits into
microsoft:masterfrom
YexuanXiao:msvc-11070187-upstream

Conversation

@YexuanXiao
Copy link
Copy Markdown
Contributor

@YexuanXiao YexuanXiao commented Apr 5, 2026

A pattern used in C++/WinRT code runs into an MSVC bug when porting to modules. I reported it here: https://developercommunity.visualstudio.com/t/11070187. This PR is a workaround for the bug, which was discovered in my fork and has been tested and confirmed to work. @DefaultRyan

void cancel()
{
auto canceller = m_canceller.exchange(cancelling_ptr, std::memory_order_acquire);
struct unique_cancellation_lock
{
cancellable_promise* promise;
~unique_cancellation_lock()
{
promise->m_canceller.store(nullptr, std::memory_order_release);
}
} lock{ this };
if ((canceller != nullptr) && (canceller != cancelling_ptr))
{
canceller(m_context);
}
}

@YexuanXiao YexuanXiao marked this pull request as draft May 22, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants