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


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))
     {


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