On Fri, 16 Jan 2026, 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):
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Actually - in the original form, with just "case 4:", this isn't an error,
just a warning:
llvm-project/libunwind/src/Unwind-seh.cpp:272:8: warning: case value not in enumerated type 'EXCEPTION_DISPOSITION' (aka
'enum _EXCEPTION_DISPOSITION') [-Wswitch]
272 | case 4 /*ExceptionExecuteHandler*/:
| ^
So theoretically we could just change the return values, but ignore this
one. But while we don't build libunwind with -Werror anywhere, we don't
want to add new known warnings anyway...
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.
No, that's not quite it.
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;
This doesn't make any difference
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;
This one actually works; presumably because "case 4" works as there _is_ a
known enum element with value 4, even though it's just a placeholder.
But ideally we shouldn't really need to go this way...
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.
Yes, this one actually works fine.
I proposed a fix for libunwind in
https://github.com/llvm/llvm-project/pull/180513 to fix these issues.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public