[clang] [WinEH] Check object unwinding in seh block only when -eha is used (PR #180108)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 06:42:35 PST 2026


zmodem wrote:

Sorry for the repeated questions, but I'd really like to understand this better :)

In https://github.com/llvm/llvm-project/pull/172287 @efriedma-quic said

> The basic issue here is that you can't generate unwind tables for both SEH and C++ exception handling in the same function.

That makes sense to me.

In our case, we are (as far as I'm aware) building with C++ exceptions disabled, so that issue should not apply to us?

That's why I don't understand why this PR gates the `err_seh_object_unwinding` diagnostic behind `getLangOpts().EHAsynch`. If the problem is mixing SEH and C++ exceptions, why not gate it behind  `getLangOpts().CXXExceptions`?

> SEH is important for Windows, it can prevent many EXCEPTION_IN_PAGE_ERROR errors. __For LLVM, it only works when using /EHa__

My understanding was that LLVM has had SEH support for a long time, but only for synchronous SEH exceptions. I.e. the following should work:

```
__try {
  foo();  // Bad memory access in here.
} __except(EXCEPTION_IN_PAGE_ERROR) {
  // ...
}
```

even without `/EHa` (as long as foo is not inlined)?

> This issue(#62606) can probably answer most questions. The key point is that the handling of SEH in LLVM is not quite the same as in MSVC. Currently, it can be said that with LLVM, the code within the __except block is only explicitly generated when using /eha.

IIUC that issue is about async SEH. We don't build with `/EHa`, but my understanding was that synchronous SEH should still work?

https://github.com/llvm/llvm-project/pull/180108


More information about the cfe-commits mailing list