This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [PATCH] Fixes for a small number of compiler warnings


Hi H.J.,

2015-03-27 14:05 GMT+01:00 H.J. Lu <hjl.tools@gmail.com>:
> I think we should add a micro
>
> #define SILENCE_UNIITITALIZED_WARNING(var) ....
>
> and do
>
> struct bfd_link_hash_entry ehdr_start_save =
>   SILENCE_UNIITITALIZED_WARNING (save);

I'm not entirely sure that's easy to accomplish. As a sidenote, GCC
also has the -Winit-self compiler warning that triggers for exactly
these cases:

https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Warning-Options.html#index-Winit_002dself-210

The only sane thing to do would be to zero-initialize the variable.
This is typically not a problem, as a decent optimizer will optimize
this away if it discovers that the initialization has no effect.

The problem with coming up with a uniform macro for this, as you
proposed, is that the syntax needed to zero-initialize depends on the
type. In some cases it needs to be 0 and in others it needs to be {}.
This is a case where the C++11 uniform initialization syntax would
have helped.

I'd suggest that we'd keep it simple for now and use just use {} here. Thoughts?

-- 
Ed Schouten <ed@nuxi.nl>


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