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]
Other format: [Raw text]

Re: suggestion for C/C++ warning


On Tue, Sep 21, 2004 at 02:48:24PM +0930, William Brodie-Tyrrell wrote:
> Would it be possible to add a warning if a struct is not completely
> initialised from a literal?  eg:
> 
> typedef struct {
> 	int a, b, c;
> } foo_t;
> 
> foo_t goodfoo = {1, 2, 3};		// ok
> foo_t badfoo = {4, 5};			// warning?
> 
> 
> Clearly use of a constructor is preferable to this initialisation style, but
> for maintenance purposes it would be very nice to catch all the places
> where a struct is badly initialised after a new member has been added to the
> definition.

-Wmissing-field-initializers
(-W enables -Wmissing-field-initializers too unless explicitely overridden).

	Jakub


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