[PATCH] D134461: [Clang] Warn when trying to deferencing void pointers in C

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 20:47:50 PDT 2022


junaire added a comment.

Sorry for missing the conversation, I was in sleeping mode at that time ;D

> This warning is quite noisy for the Linux kernel due to a couple of places where a void * is dereferenced as part of compile time checking.

I'm actually surprised to see that, I thought Clang is just "following" what GCC does, (more strictly in fact). So I wonder why there's no issue for GCC but Clang?

> All this said, I think in both cases we want `-pedantic` to warn on these situations even if we would silence by default. e.g.,
>
>   void func(void *vp) {
>     sizeof(void); // No warning by default, does get pedantic warning
>     sizeof(*vp); // No warning by default, does get pedantic warning
>     sizeof(*(vp))`; // No warning by default, does get pedantic warning
>     void inner(typeof(*vp)); // No warning by default, does get pedantic warning
>   
>     (void)*vp; // Warning by default
>   }
>
> What do folks think of that idea?

Nice summary!

> Thank you for the offer! @junaire -- would you like to try making the changes?

Sure, I'm willing to submit another patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134461/new/

https://reviews.llvm.org/D134461



More information about the cfe-commits mailing list