Skip to content

Conversation

silver-popov
Copy link
Contributor

Implicit conversion of int to enum causes an error in CLang 21.

@silver-popov silver-popov requested a review from a team as a code owner September 17, 2025 09:12
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-libunwind

Author: Igor Popov (silver-popov)

Changes

Implicit conversion of int to enum causes an error in CLang 21.


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

1 Files Affected:

  • (modified) libunwind/src/Unwind-seh.cpp (+2-2)
diff --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp
index 8b83f10615f22..60571b3079887 100644
--- a/libunwind/src/Unwind-seh.cpp
+++ b/libunwind/src/Unwind-seh.cpp
@@ -163,7 +163,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
     // If we were called by __libunwind_seh_personality(), indicate that
     // a handler was found; otherwise, initiate phase 2 by unwinding.
     if (ours && ms_exc->NumberParameters > 1)
-      return 4 /* ExceptionExecuteHandler in mingw */;
+      return (EXCEPTION_DISPOSITION)4 /* ExceptionExecuteHandler in mingw */;
     // This should never happen in phase 2.
     if (IS_UNWINDING(ms_exc->ExceptionFlags))
       _LIBUNWIND_ABORT("Personality indicated exception handler in phase 2!");
@@ -181,7 +181,7 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx,
     // a handler was found; otherwise, it's time to initiate a collided
     // unwind to the target.
     if (ours && !IS_UNWINDING(ms_exc->ExceptionFlags) && ms_exc->NumberParameters > 1)
-      return 4 /* ExceptionExecuteHandler in mingw */;
+      return (EXCEPTION_DISPOSITION)4 /* ExceptionExecuteHandler in mingw */;
     // This should never happen in phase 1.
     if (!IS_UNWINDING(ms_exc->ExceptionFlags))
       _LIBUNWIND_ABORT("Personality installed context during phase 1!");

@MaskRay MaskRay requested a review from mstorsjo September 19, 2025 16:25
@mstorsjo
Copy link
Member

This had me a bit surprised, because I build the latest libunwind nightly, with the latest clang, and haven't run into this.

But the reason for that, is that mingw has got EXCEPTION_DISPOSITION defined as int, see https://github.com/mingw-w64/mingw-w64/blob/v13.0.0/mingw-w64-headers/crt/excpt.h#L19-L26 - while MSVC headers have it as an actual enum.

So this issue is observable only if building in MSVC mode. IIRC there are a few other issues if building libunwind in MSVC mode as well (and libunwind isn't really very useful for much in a MSVC mode environment anyway - but if you have a specific use case for it there I'm interested in hearing!).

Anyway, the change itself looks fine to me (although we perhaps should use static_cast<>() instead).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants