Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Taras Tsugrii <ttsugrii@fb.com>
To: gdb-patches@sourceware.org
Cc: Taras Tsugrii <ttsugrii@fb.com>
Subject: [PATCH] Fix implicit conversion warning produced by clang
Date: Tue, 14 Jun 2016 17:56:00 -0000	[thread overview]
Message-ID: <1465926942-37759-1-git-send-email-ttsugrii@fb.com> (raw)

When compiling with clang, which is part of Xcode 7.3, following warnings
are emitted:
objcopy.c:224:50: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
static enum bfd_link_discard do_elf_stt_common = unchanged;
                             ~~~~~~~~~~~~~~~~~   ^~~~~~~~~
objcopy.c:4290:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
            do_elf_stt_common = elf_stt_common;
                              ~ ^~~~~~~~~~~~~~
objcopy.c:4292:26: error: implicit conversion from enumeration type 'enum bfd_link_elf_stt_common' to different enumeration type 'enum bfd_link_discard' [-Werror,-Wenum-conversion]
            do_elf_stt_common = no_elf_stt_common;
                              ~ ^~~~~~~~~~~~~~~~~
3 errors generated.

This is risky, since essentially there is a coupling between 2 different
enum orderings. Also since by default warnings are promoted to errors
it breaks default build.

To reproduce: ./configure && make
Verified by: ./configure && make # above warnings disappear
---
 binutils/ChangeLog | 4 ++++
 binutils/objcopy.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ff8161a..08be889 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-14  Taras Tsugrii  <taras.tsugriy@gmail.com>
+
+	* objcopy.c: Fix clang implicit conversion warning.
+
 2016-06-14  Alan Modra  <amodra@gmail.com>
 
 	* ar.c: Expand uses of bfd_my_archive.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 06fcea3..76170cb 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -221,7 +221,7 @@ static enum
 } do_debug_sections = nothing;
 
 /* Whether to generate ELF common symbols with the STT_COMMON type.  */
-static enum bfd_link_discard do_elf_stt_common = unchanged;
+static enum bfd_link_elf_stt_common do_elf_stt_common = unchanged;
 
 /* Whether to change the leading character in symbol names.  */
 static bfd_boolean change_leading_char = FALSE;
-- 
2.8.0-rc2


             reply	other threads:[~2016-06-14 17:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 17:56 Taras Tsugrii [this message]
2016-06-14 19:08 ` John Baldwin
2016-06-14 21:03   ` Pedro Alves
2016-06-15  8:52 ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465926942-37759-1-git-send-email-ttsugrii@fb.com \
    --to=ttsugrii@fb.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox