aaron.ballman added a subscriber: jwakely.
aaron.ballman added a comment.

In D157879#4604288 <https://reviews.llvm.org/D157879#4604288>, @phosek wrote:

> Note that there's an ongoing discussion on the GCC bug 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868 whether 
> `-Wmissing-field-initializers` should apply to both C and C++ or just C.

Thank you for posting this! I'm with @jwakely on this: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868#c3 -- the warning is for 
people who want to be told they've not explicitly specified all of the 
initializers, it is not for telling you "this hasn't been initialized". I think 
the desire makes as much sense in C++ as it does in C, but this is more of a 
style warning than a correctness warning.

In D157879#4604471 <https://reviews.llvm.org/D157879#4604471>, @ianloic wrote:

> In D157879#4604233 <https://reviews.llvm.org/D157879#4604233>, @aeubanks 
> wrote:
>
>> ah I thought this was in `-Wall` but it's not
>>
>> the struct is
>>
>>   struct Foo {
>>     const void* buffer;
>>     uint32_t capacity;
>>     uint32_t reserved;
>>   };
>>
>> where `reserved` isn't explicitly initialized. that seems like reasonable 
>> code, but I suppose we can just explicitly initialize `reserved` here
>
> FWIW, if this is the specific piece of code that led me to this conversation, 
> that declaration is in a header which at least in theory is supposed to 
> remain compatible with C. It's inside `extern "C" { ... }` even. We can't add 
> explicit initialize `reserved` and keep the definition C comaptible.

Ouch, yeah, that does make it a challenge. But why is 
`-Wmissing-field-initializers` enabled in the first place for the code? It 
seems like there are fields you *don't* want explicit initialization for, so 
perhaps the answer is to disable the diagnostic for those types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157879

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to