[cfe-dev] -Wmissing-field-initializers

John McCall rjmccall at apple.com
Mon Feb 20 13:14:29 PST 2012


On Feb 20, 2012, at 12:40 PM, Sean McBride wrote:
> On Mon, 20 Feb 2012 12:16:36 -0800, John McCall said:
>> -Wmissing-field-initializers does have a special case for intentional
>> uses of the language's default-zero-initialization rules.  However, that
>> special case is spelled {}, not {0}.  If you feel that this is a really
>> common idiom for zero-initialization, we could also add it, but I'd
>> really prefer not to, because it neuters -Wmissing-field-initializers on
>> an interesting class of bugs.
> 
> But using {}, as you suggest, gives:
> 
> warning: use of GNU empty initializer extension [-pedantic,-Wgnu]

This is one of my consistent blind spots;  it surprises me every single time.
Although we were talking about C++ here, where {} is permitted.

> One seems trapped between one warning or the other.

I agree that something should probably be done for the C case.
If that means white-listing {0}, okay.  I'd still prefer to only do so in C,
since the better option is available in C++.

John.



More information about the cfe-dev mailing list