[PATCH] Fix a warning when initializing symbol_flags

Hans-Peter Nilsson hp@bitrange.com
Sat Sep 26 19:21:51 GMT 2020



On Sat, 26 Sep 2020, Alan Modra via Binutils wrote:

> On Fri, Sep 25, 2020 at 05:42:24PM -0700, Saagar Jha wrote:
> > Clang on certain platforms (such as arm64) will warn if a struct is
> > partially initialized:
> >
> > symbols.c:199:35: error: missing field 'written' initializer [-Werror,-Wmissing-field-initializers]
> > 2895  symbol_entry_t needle = { { { 0 }, hash, name, 0, 0, 0 } };
> >
> > If we use empty braces we have the same effect but avoid the warning.
>
> But on gcc-4.9 this results in:
>
> symbols.c: In function ?symbol_entry_find?:
> symbols.c:199:3: error: missing initializer for field ?local_symbol? of ?struct symbol_flags? [-Werror=missing-field-initializers]
>    symbol_entry_t needle = { { { }, hash, name, 0, 0, 0 } };
>    ^
> symbols.c:39:16: note: ?local_symbol? declared here
>    unsigned int local_symbol : 1;
>                 ^
>
> So I don't think we should apply your patch.

How about a memset 0 and setting .hash and .name?

I had to do that locally for an older gcc, that had a similar
warning.  I prefered that over 11 (IIRC) "0," and having to
keep them straight. :)

brgds, H-P


More information about the Binutils mailing list