[clang] [C] Add (new) -Wimplicit-void-ptr-cast to -Wc++-compat (PR #136855)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 18 05:02:46 PDT 2025
AaronBallman wrote:
> Hi @AaronBallman I noticed that this commit makes a difference on the example below.
>
> ```
> #include <stdatomic.h>
> typedef const struct T * T_Ref;
> static T_Ref _Atomic x = ATOMIC_VAR_INIT((void*)NULL);
> ```
>
> After this commit, the AST of the global variable declaration changes---a level of `-ImplicitCastExpr '_Atomic(CFStringRef)' <NonAtomicToAtomic>` is removed, resulting in a new `error: initializer element is not a compile-time constant`. (https://godbolt.org/z/aK8E9o47E)
That looks like a bug to me, though `ATOMIC_VAR_INIT` was deprecated in C17 and removed in C23 because it isn't a necessary API for initialization. I think it's worth filing an issue over.
Did you bisect it to this commit or was this a guess at the cause? I'm not certain I see how we could drop the atomic conversion from these changes (but the code is dense enough that it may be easy to miss).
https://github.com/llvm/llvm-project/pull/136855
More information about the cfe-commits
mailing list