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: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Hans-Peter Nilsson <hp at bitrange dot com>, Ed Schouten <ed at nuxi dot nl>, Binutils <binutils at sourceware dot org>
- Date: Wed, 1 Apr 2015 14:18:57 +1030
- Subject: Re: [PATCH] Fixes for a small number of compiler warnings
- Authentication-results: sourceware.org; auth=none
- References: <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> <CABh_MKmKPHAfVo5Q2BkBnQuGFk-x+5a3j46KtXgF9_af2UHrCg at mail dot gmail dot com> <CABh_MKnE8EBOCuTCofXi2CsWsOVq5xtC+cPqZB-NgotzKFFGLg at mail dot gmail dot com> <20150401003744 dot GN26234 at bubble dot grove dot modra dot org> <alpine dot BSF dot 2 dot 02 dot 1503312120010 dot 87955 at arjuna dot pair dot com> <20150401024707 dot GP26234 at bubble dot grove dot modra dot org> <CAMe9rOrpdXYXG-Lsq3UVCnLxwTk-qFAKZE4Ms5UALquTa9cSNA at mail dot gmail dot com> <20150401032705 dot GQ26234 at bubble dot grove dot modra dot org> <CAMe9rOpi+SxEp8BTacMjuaQ_EcYusd9ks_dbHgNTfUwg0bWCDw at mail dot gmail dot com>
On Tue, Mar 31, 2015 at 08:32:35PM -0700, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 8:27 PM, Alan Modra <amodra@gmail.com> wrote:
> > On Tue, Mar 31, 2015 at 07:53:36PM -0700, H.J. Lu wrote:
> >> This becomes a regression with the older GCC.
> >
> > Yes. I'd rather cause that than have warnings with more recent gcc
> > versions.. I also agree that we shouldn't worry too much about
> > compilers other than gcc, and I know that self-assignment is something
> > that C++ programmers need to worry about which is no doubt why the
> > warning is on for Clang.
> >
> > I did consider just reverting the previous patch, but fixing a warning
> > with a self-assignment just looks horrible to me, particularly when
> > the warning is about an uninitialized variable. I mean, it looks to
> > me that a self-assignment actually creates an uninitialized variable
> > access at the abstract level, when there wasn't one there before!
>
> For this particular case, self-assignment causes no harm since
> the variable will be initialized.
I didn't say there was any harm, just that I dislike the style and why
I dislike it.
>
> Will
>
> struct bfd_link_hash_entry ehdr_start_save = { 0 };
>
> for all compilers?
No joy. gcc-4.7.2
eelf64ppc.c: In function âgldelf64ppc_before_allocationâ:
eelf64ppc.c:1899:10: error: missing braces around initializer [-Werror=missing-braces]
eelf64ppc.c:1899:10: error: (near initialization for âehdr_start_save.rootâ) [-Werror=missing-braces]
eelf64ppc.c:1899:10: error: missing initializer [-Werror=missing-field-initializers]
eelf64ppc.c:1899:10: error: (near initialization for âehdr_start_save.typeâ) [-Werror=missing-field-initializers]
--
Alan Modra
Australia Development Lab, IBM