[PATCH] D146194: NOT report the warning that unnamed bitfields are uninitialized.

Tang Wenyu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 04:15:15 PDT 2023


Tedlion requested review of this revision.
Tedlion added a comment.

In D146194#4198870 <https://reviews.llvm.org/D146194#4198870>, @steakhal wrote:

> Thanks for looking into this.
>
> I could not reproduce the issue with the following test code:  https://godbolt.org/z/hsY9PTKGz
>
>   struct A {
>     unsigned x : 3;
>     unsigned : 29; 
>     unsigned y;
>   };
>   void func1(A a);
>   
>   void func2() {
>     A a = {0};
>     func1(a); // no-warning here on trunk
>   }
>
> I'd recommend adding a test that would demonstrate that before your fix the test would diagnose a FP and after your fix, the FP would disappear.
> Without tests, unfortunately, we cannot accept patches.

Thanks for reviewing. I have tried the code as C++ source, no warning is reported. However, clang gives the wrong warning when processing the code as C source. Try the following: https://godbolt.org/z/6ET6rnb4z


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146194



More information about the cfe-commits mailing list