This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] struct member warning
- To: haible at ilog dot fr (Bruno Haible)
- Subject: Re: [patch] struct member warning
- From: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Date: Mon, 29 Jun 1998 14:18:59 +0200 (CEST)
- Cc: egcs-patches at cygnus dot com
| Jeffrey A. Law writes:
|
| > I made some minor comment clarifications and installed this patch.
|
| Thanks. Additionally, here is a documentation patch for it.
|
| *** egcs-19980621/gcc/invoke.texi.bak Sun Jun 28 22:10:19 1998
| --- egcs-19980621/gcc/invoke.texi Sun Jun 28 22:13:57 1998
| ***************
| *** 1531,1536 ****
| --- 1531,1546 ----
| struct t @{ struct s h; int i; @};
| struct t x = @{ 1, 2, 3 @};
| @end smallexample
| +
| + @item
| + An aggregate has an initializer which does not initialize all members.
| + For example, the following code would cause such a warning, because
| + @code{x.h} would be implicitly initialized to zero:
| +
| + @smallexample
| + struct s @{ int f, g, h; @};
| + struct s x = @{ 3, 4 @};
| + @end smallexample
| @end itemize
|
| @item -Wtraditional
Wouldn't it be better to suppress this warning when the last
parameter is a `0' or NULL ?
I know it is often used to initialize "the rest", ie:
struct s { int f, g, h, i, j; char *p; };
struct s x = { 3, 4, 0 };
should give no warning.
struct s { int f, g, h, i, j; char *p; };
struct s x = { 1, 2, 3, 4, NULL };
should give a warning though.
I agree its kind of fuzzy, but it would be annoying as hell
to be forced to initialize all members with 0 just to get
rid of the warning.
Alternatively, the warning could be suppressed when
both: the last initializing element is 0 and *more* then
three elements are left uninitialized. Such a case is likely on purpose.
--
Carlo Wood <carlo@runaway.xs4all.nl>