2009/11/18 Mark Mitchell:
> Joe Buck wrote:
>
>> I think that the cleanest way is to suppress the warning for structs
>> with one member
>
> And recursively?
>
> So that:
>
> struct A { int i; };
> struct B { struct A a };
> struct C { struct B b };
> struct C c = { 1 };
>
> does not trigger the warning?
I think not warning here is fine.
> What if struct B is now:
>
> struct B { struct A a; int j; };
>
> and I write:
>
> struct C c = { 1, 2 };
>
> ?
This still has exactly two initialisers for exactly two objects, so I
think it's OK. I'm concerned about missing braces when the meaning of
the code may not be what you expect.
e.g.
struct X { int i; };
struct Y { struct X x; int j; };
Y y = { 1, 2 };
is OK, but if someone changes X to:
struct X { int i; int j };
then I want the initialisation of y to warn, which it already does
because of -Wmissing-field-initializers. But maybe I should just use
-Wno-missing-braces and leave the missing braces warning for those who
find it useful.