This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [patch] struct member warning


> It is a pitfall in C and C++ that a structure can have a static initializer
> which lists less elements that the structure has. The remaining elements
> are silently initialized with 0. This may or may not be what the programmer
> intended. If the programmer intends this, she can easily write the 0es
> explicitly. Here is a patch which adds a warning (triggered by
> "-Wuninitialized").

I think that is the wrong switch.  Initialized to zero is considerably
different from uninitialized.  If you must have a warning for this
construct (which is sometimes essential for portable code, i.e. to
initialize structs with union members), then IMO it should have a
more fitting name, like -Wimplicit-initialization.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]