[clang] [Clang] Fix assertion when __block is used on global variables in C mode (PR #183988)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 26 09:02:59 PDT 2026


ojhunt wrote:

> > > @nico This wasn't an intentional change, but it seems my code modification has indeed caused some side effects. I suspect it might be because my check on `hasLocalStorage()` was too aggressive. I'll fix it as soon as I find the specific cause.
> > 
> > 
> > Ah, that was a screw up on my part when reviewing. This should have been if `VD && !VD->hasLocalStorage()`.
> > In addition to objc, we'll want to have test cases for instance and static fields in C and C++ records, and also possibly block and lambda captures of `__block` variables.
> 
> Oh, I didn't even notice I added an extra exclamation mark (・_・;)

the check was written to avoid a null dereference, and it did do that, but it had the effect of of being overly permissive.

@nico thanks for spotting this, and tracking this down as the cause

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


More information about the cfe-commits mailing list