On Friday 16 January 2026 18:20:40 LIU Hao wrote:
> 在 2026-1-16 17:58, Martin Storsjö 写道:
> > That does fix the errors for returning this value, but it still doesn't
> > help with the case for the switch case:
> >
> > /home/martin/code/llvm-mingw/llvm-project/libunwind/src/Unwind-seh.cpp:272:8:
> > error: case value is not a constant expression
> > 272 | case EXCEPTION_DISPOSITION(4):
> > | ^~~~~~~~~~~~~~~~~~~~~~~~
> >
> > /home/martin/code/llvm-mingw/llvm-project/libunwind/src/Unwind-seh.cpp:272:8:
> > error: case value is not a constant expression
> > 272 | case static_cast<EXCEPTION_DISPOSITION>(4):
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> I think it's because the underlying type of `EXCEPTION_DISPOSITION` is not
> fixed, and Clang somehow allocates `unsigned int:2` for it, which is not
> sufficient for the value 4.
>
> To work around that, we can either declare a placeholder value
>
> typedef enum _EXCEPTION_DISPOSITION {
> ExceptionContinueExecution = 0,
> ExceptionContinueSearch = 1,
> ExceptionNestedException = 2,
> ExceptionCollidedUnwind = 3,
> __EXCEPTION_DISPOSITION_placeholder_for_libunwind = 4
> } EXCEPTION_DISPOSITION;
>
> or declare a fixed underlying type
>
> typedef enum _EXCEPTION_DISPOSITION
> #if defined __cplusplus && __cplusplus >= 201103L
> : int
> #endif
> {
> ExceptionContinueExecution = 0,
> ExceptionContinueSearch = 1,
> ExceptionNestedException = 2,
> ExceptionCollidedUnwind = 3
> } EXCEPTION_DISPOSITION;
Another option would be to change the switch in Unwind-seh.cpp from
switch (ms_act) {
To
switch (int(ms_act)) {
And then the switch can use either enum values or raw integer numbers.
I played a bit with it on: https://godbolt.org/z/vWKfYr3nT
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public