Skip to content

[libcxx][NFC] Address -Wmicrosoft-cast in MSVC's exception_ptr - #210570

Merged
petrhosek merged 1 commit into
llvm:mainfrom
petrhosek:microsoft-excptptr-warnings
Jul 20, 2026
Merged

[libcxx][NFC] Address -Wmicrosoft-cast in MSVC's exception_ptr#210570
petrhosek merged 1 commit into
llvm:mainfrom
petrhosek:microsoft-excptptr-warnings

Conversation

@petrhosek

@petrhosek petrhosek commented Jul 19, 2026

Copy link
Copy Markdown
Member

This was introduced as part of #94977. Rather than suppressing the warning with #pragma clang diagnostic ignored, we use reinterpret_cast to avoid the implicit conversion.

@petrhosek
petrhosek requested a review from a team as a code owner July 19, 2026 05:18
@petrhosek petrhosek added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 19, 2026
@petrhosek petrhosek changed the title [libcxx] Suppress -Wmicrosoft-cast in MSVC's exception_ptr [libcxx][NFC] Suppress -Wmicrosoft-cast in MSVC's exception_ptr Jul 19, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-libcxx

Author: Petr Hosek (petrhosek)

Changes

This was introduced as part of #94977.


Full diff: https://github.com/llvm/llvm-project/pull/210570.diff

1 Files Affected:

  • (modified) libcxx/src/support/runtime/exception_pointer_msvc.ipp (+3-2)
diff --git a/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/libcxx/src/support/runtime/exception_pointer_msvc.ipp
index 3102d1ee93db2..4b877deeec7bc 100644
--- a/libcxx/src/support/runtime/exception_pointer_msvc.ipp
+++ b/libcxx/src/support/runtime/exception_pointer_msvc.ipp
@@ -141,7 +141,7 @@ void __copy_exception_object(void* __dest, const void* __src, const CatchableTyp
 #if _EH_RELATIVE_TYPEINFO
   const auto __copy_func = reinterpret_cast<void*>(__throw_image_base + __type->copyFunction);
 #else // _EH_RELATIVE_TYPEINFO
-  const auto __copy_func = __type->copyFunction;
+  const auto __copy_func = reinterpret_cast<void*>(__type->copyFunction);
 #endif // _EH_RELATIVE_TYPEINFO
 
   const auto __adjusted = __AdjustPointer(const_cast<void*>(__src), __type->thisDisplacement);
@@ -204,7 +204,8 @@ struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__) __exception_ptr_normal final :
           __call_member_function_0(__cpp_eh_record.params.pExceptionObject,
                                    reinterpret_cast<void*>(__throw_info->pmfnUnwind + __throw_image_base));
 #else // _EH_RELATIVE_TYPEINFO
-          __call_member_function_0(__cpp_eh_record.params.pExceptionObject, __throw_info->pmfnUnwind);
+          __call_member_function_0(__cpp_eh_record.params.pExceptionObject,
+                                   reinterpret_cast<void*>(__throw_info->pmfnUnwind));
 #endif // _EH_RELATIVE_TYPEINFO
         } else if (__type->properties & CT_IsWinRTHandle) {
           const auto* __unknown = *static_cast<IUnknown* const*>(__cpp_eh_record.params.pExceptionObject);

@frederick-vs-ja

Copy link
Copy Markdown
Contributor

Most LGTM. The PR title looks a bit ambiguous to me. Perhaps it's better to clarify that we're using reinterpret_cast properly instead of using #pragma clang diagnostic ignored.

@petrhosek petrhosek changed the title [libcxx][NFC] Suppress -Wmicrosoft-cast in MSVC's exception_ptr [libcxx][NFC] Address -Wmicrosoft-cast in MSVC's exception_ptr Jul 19, 2026
@petrhosek

Copy link
Copy Markdown
Member Author

Most LGTM. The PR title looks a bit ambiguous to me. Perhaps it's better to clarify that we're using reinterpret_cast properly instead of using #pragma clang diagnostic ignored.

Done.

@frederick-vs-ja
frederick-vs-ja requested a review from nico July 19, 2026 23:54
@petrhosek
petrhosek merged commit 16ffd27 into llvm:main Jul 20, 2026
84 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in LLVM Release Status Jul 20, 2026
@petrhosek

Copy link
Copy Markdown
Member Author

/cherry-pick 16ffd27

1 similar comment
@frederick-vs-ja

Copy link
Copy Markdown
Contributor

/cherry-pick 16ffd27

@llvmbot

llvmbot commented Jul 20, 2026

Copy link
Copy Markdown
Member

/pull-request #210765

dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 22, 2026
…210570)

This was introduced as part of llvm#94977. Rather than suppressing the
warning with `#pragma clang diagnostic ignored`, we use
`reinterpret_cast` to avoid the implicit conversion.

(cherry picked from commit 16ffd27)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

Development

Successfully merging this pull request may close these issues.

3 participants