This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fixes for a small number of compiler warnings
- From: Ed Schouten <ed at nuxi dot nl>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sat, 28 Mar 2015 08:48:19 +0100
- Subject: Re: [PATCH] Fixes for a small number of compiler warnings
- Authentication-results: sourceware.org; auth=none
- References: <CABh_MK=meHjQHZH9Cssu3xSgsrehcar0-COMZSJf0cHZTKxH4A at mail dot gmail dot com> <20150327000715 dot GY26234 at bubble dot grove dot modra dot org> <CABh_MKmxfVGU9b=vD9yHdUWXtkN7==Ptmu4h3izQPGCzsa=b=g at mail dot gmail dot com> <CAMe9rOrys_QG+0opphc9AXn5=Z-Df4Nk0WUFTJEy-dy_ux8Y=g at mail dot gmail dot com>
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>