From b7c8a8e834afbbe9da9cec185d212a26ffd7aefb Mon Sep 17 00:00:00 2001 From: Georgii Rymar Date: Sat, 15 Feb 2020 18:34:06 +0300 Subject: [PATCH] [obj2yaml] - Fix a -Wsign-compare warning gived by GCC 9.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I was reported that with commit: https://github.com/llvm/llvm-project/commit/d3963051c490 gcc-9.2 is giving the warning below. This should help (I have no gcc 9.2 to test). [ 57%] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/elf2yaml.cpp.o /llvm/tools/obj2yaml/elf2yaml.cpp: In instantiation of ‘llvm::Expected {anonymous}::ELFDumper::dump() [with ELFT = llvm::object::ELFType]’: /llvm/tools/obj2yaml/elf2yaml.cpp:1218:31: required from ‘llvm::Error elf2yaml(llvm::raw_ostream&, const llvm::object::ELFFile&) [with ELFT = llvm::object::ELFType]’ /llvm/tools/obj2yaml/elf2yaml.cpp:1231:47: required from here /llvm/tools/obj2yaml/elf2yaml.cpp:207:41: warning: comparison of integer expressions of different signedness: ‘llvm::support::detail::packed_endian_specific_integral::value_type’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare] 207 | if (!SymTab || SymTabShndx->sh_link != SymTab - Sections.begin()) /llvm/tools/obj2yaml/elf2yaml.cpp: In instantiation of ‘llvm::Expected {anonymous}::ELFDumper::dump() [with ELFT = llvm::object::ELFType]’: ... --- llvm/tools/obj2yaml/elf2yaml.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp index d399b95..cb06e09 100644 --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -204,7 +204,8 @@ template Expected ELFDumper::dump() { // We need to locate the SHT_SYMTAB_SHNDX section early, because it might be // needed for dumping symbols. if (SymTabShndx) { - if (!SymTab || SymTabShndx->sh_link != SymTab - Sections.begin()) + if (!SymTab || + SymTabShndx->sh_link != (unsigned)(SymTab - Sections.begin())) return createStringError( obj2yaml_error::not_implemented, "only SHT_SYMTAB_SHNDX associated with SHT_SYMTAB are supported"); -- 2.7.4