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: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Ed Schouten <ed at nuxi dot nl>
- Cc: Hans-Peter Nilsson <hp at bitrange dot com>, Binutils <binutils at sourceware dot org>
- Date: Wed, 1 Apr 2015 08:16:49 -0700
- Subject: Re: [PATCH] Fixes for a small number of compiler warnings
- Authentication-results: sourceware.org; auth=none
- References: <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> <20150401034857 dot GR26234 at bubble dot grove dot modra dot org> <CAMe9rOrYaZpnnRM38k9tqJ_cbNK5j_3wLm+gJeQh_bY4nq2D9A at mail dot gmail dot com> <20150401053346 dot GS26234 at bubble dot grove dot modra dot org> <CAMe9rOpLsusSkfLFaKrocdAiPPXHN5J30p=zgdm3ARKp_SqSww at mail dot gmail dot com> <CABh_MKmzuXd94za=54W2RmTLse=41HBm_05MsLg3xy1b5hO3Uw at mail dot gmail dot com>
On Wed, Apr 1, 2015 at 5:21 AM, Ed Schouten <ed@nuxi.nl> wrote:
> Hi,
>
> Earlier today I tried to reply to this conversation from my phone, but
> it seems my email bounced because it used HTML. Second attempt.
>
> 2015-04-01 13:08 GMT+02:00 H.J. Lu <hjl.tools@gmail.com>:
>> I don't think there is a perfect solution. But I don't want to turn off
>> -Werror for older GCC.
>
> We could consider using a memset call instead of attempting to use an
> initializer list:
>
> struct bfd_link_hash_entry ehdr_start_save;
> memset(&ehdr_start_save, 0, sizeof(ehdr_start_save));
>
> That way both compiler warnings (self-initialization and incomplete
> initializer list) are suppressed. It would make sense to put a comment
> next to it, so we don't forget to remove it in the very far future:
>
> /* memset() to keep GCC < 4.n happy. */
>
I checked in this patch.
--
H.J.
---
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ac1abae..1348f46 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Work
+ around a GCC uninitialized warning bug fixed in GCC 4.6.
+
2015-04-01 Tejas Belagod <tejas.belagod@arm.com>
* emultempl/aarch64elf.em
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index ece2fb0..4dd71ab 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1412,7 +1412,12 @@ gld${EMULATION_NAME}_before_allocation (void)
asection *sinterp;
bfd *abfd;
struct elf_link_hash_entry *ehdr_start = NULL;
+#if defined(__GNUC__) && GCC_VERSION < 4006
+ /* Work around a GCC uninitialized warning bug fixed in GCC 4.6. */
+ struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save;
+#else
struct bfd_link_hash_entry ehdr_start_save;
+#endif
if (is_elf_hash_table (link_info.hash))
{