Re: -Wmissing-field-initializers got shot in the leg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30 December 2016 at 09:26, Georg GCC User wrote:
> Hi,
>
> -Wmissing-field-initializers is documented to do what its name
> suggests, i.e. warn about missing initialisers for members,
> but only provided that the programmer does *not* specify
> designators for members of a struct, say. Thus, in C,
>
> struct R {
>   int a;
>   int b;
>   int newField; /* added at a later stage. */
> };
>
> and then given an initialiser placed some time before the addition
> of .newField, somewhere else,
>
>   struct R test = (struct R) {
>    .a = 42,
>    .b = -1
>   };
>
> passes without warning, as documented. This can cause
> the programmer to manually scan all uses of struct R for possibly
> missing initialisation.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
> looks light it might be causing this behaviour.

No, it's nothing to do with that. The behaviour you've observed with
designated initializers has been how it works since the warning option
was first added back in 2004, see https://gcc.gnu.org/r85638

> I understand that the relaxation request of #36750 was inspired
> by C++ {} initialisation, as well as the 0 case. But from a software
> development point of view (as in longer development process, teams, etc.),
> this behaviour of suppressing warnings is disturbing.

Suppressing the warning makes sense when using {0} in C, or {} in C++.
But that's not your situation, where you have some initializers but
others are missing.

> And I don't want to drop designators just because omitting
> them and loosing information will make GCC warn again.
> Imagine larger structures.
>
> Is there some other way to make GCC warn, or will a change request
> be in order?

I think so, since the current behaviour is documented and intentional.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux