[clang] [Clang][CodeGen] Track EH cleanup depth for guarded init and pop correctly (PR #199508)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 17 14:53:22 PDT 2026


efriedma-quic wrote:

> This can be fixed if the block is copied via `__Block_copy` and assigned it to b after the static initialization. b then points to a heap block, so later calls are fine. But the captures have to be kept alive until the block is copied.

There's no way to run the `__Block_copy` in time to prevent races (unless you stick it in the initializer itself, in which case it's like the ARC case).

> Even without the `__Block_copy`, the function is well defined if it only runs once. I don't think anything in the standard makes the code invalid just because it can't be invoked more than once.

It's self-consistent, I guess, given a rule that a block literals always have automatic storage duration, but it's basically never what anyone would want.

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


More information about the cfe-commits mailing list