Subject: Re: -Wno-missing-init?
To: None <>
From: Alan Barrett <>
List: tech-toolchain
Date: 03/15/2007 08:36:19
On Wed, 14 Mar 2007, der Mouse wrote:
> I'm going to add -W{no-,}missing-init, for fine-grained control over
> incomplete initializer warnings.  In particular, I don't want those
> warnings, but I do want the rest of the stuff -W gets me

That sounds useful.

I'd actually like to get warnings about missing braces and missing
initialisers in most cases, but not in the case where a struct is
initialised by {0}.  For example, I want a warning about missing braces
if I do

	struct s {int i;};
	struct s array[2] = {1, 2}; /* should be {{1}, {2}} */

and I want a warning about incomplete initialisers for this:

	struct t {int i, j;};
	struct t array[2] = {{1}, {2}}; /* should be {{1, 0}, {2, 0}} */

but I don't want any warning at all if I do

	struct opaque foo = {0};
	struct opaque array[2] = {{0}, {0}};

NetBSD's code is riddled with struct assignments that use

	structvar = {.somefield = 0};

to get the effects that should be available from

	structvar = {0};

I consider the version with {0} to be better style, the C99 standard
specifies the same meaning for both, but the version with {0} triggers
from warnings from gcc.

--apb (Alan Barrett)