[cfe-dev] -Wmissing-field-initializers

David Blaikie dblaikie at gmail.com
Mon Feb 20 09:04:41 PST 2012


On Mon, Feb 20, 2012 at 8:48 AM, Howard Hinnant <hhinnant at apple.com> wrote:
> I'm getting the following warning on building libc++:
>
> ../src/locale.cpp:4554:14: warning: missing field 'tm_min' initializer [-Wmissing-field-initializers]
>    tm t = {0};
>             ^
> 1 warning generated.
>
> I know what the warning is saying.  My question is why?  I presume tm_min is getting initialized to 0 as intended.  The above is pretty standard fare (I thought) for zero-initializing an aggregate.  Isn't this warning a little too chatty?

It seems to me a little hard to separate this case from the general
case the warning is trying to implement - except that, yes, this seems
like a fairly common idiom even if it's no more useful than {}.

But someone had the same question about GCC with a more in-depth
rationalization (apparently {0} has special behavior in C99 that
differs from {}) & so they changed their behavior do fulfill your
request ( http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750 ). We
should probably do the same, I suppose.

- David




More information about the cfe-dev mailing list