r320750 - Fix many -Wsign-compare and -Wtautological-constant-compare warnings.

Galina Kistanova via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 14:43:48 PST 2017


I fixed this with r320868.

Thanks

Galina

On Thu, Dec 14, 2017 at 5:43 PM, Galina Kistanova <gkistanova at gmail.com>
wrote:

> Hello Zachary,
>
> It looks like this commit added an error to one of our builders:
> http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/3735
>
> . . .
> FAILED: /usr/local/gcc-7.1/bin/g++-7.1   -DGTEST_HAS_RTTI=0 -D_DEBUG
> -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
> -D__STDC_LIMIT_MACROS -Ilib/Object -I/home/buildslave/am1i-slv2/
> ubuntu-gcc7.1-werror/llvm/lib/Object -Iinclude
> -I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/include
> -Wno-noexcept-type -fPIC -fvisibility-inlines-hidden -Werror
> -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings
> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
> -ffunction-sections -fdata-sections -O3  -fPIC   -UNDEBUG  -fno-exceptions
> -fno-rtti -MD -MT lib/Object/CMakeFiles/LLVMObject.dir/COFFImportFile.cpp.o
> -MF lib/Object/CMakeFiles/LLVMObject.dir/COFFImportFile.cpp.o.d -o
> lib/Object/CMakeFiles/LLVMObject.dir/COFFImportFile.cpp.o -c
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/
> Object/COFFImportFile.cpp
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/Object/COFFImportFile.cpp:
> In member function ‘llvm::NewArchiveMember llvm::object::{anonymous}::
> ObjectFactory::createImportDescriptor(std::vector<unsigned char,
> std::allocator<unsigned char> >&)’:
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/
> Object/COFFImportFile.cpp:191:28: error: enumeral and non-enumeral type
> in conditional expression [-Werror=extra]
>        u16(is32bit(Machine) ? IMAGE_FILE_32BIT_MACHINE : 0),
>            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/Object/COFFImportFile.cpp:
> In member function ‘llvm::NewArchiveMember llvm::object::{anonymous}::
> ObjectFactory::createNullImportDescriptor(std::vector<unsigned char,
> std::allocator<unsigned char> >&)’:
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/
> Object/COFFImportFile.cpp:327:28: error: enumeral and non-enumeral type
> in conditional expression [-Werror=extra]
>        u16(is32bit(Machine) ? IMAGE_FILE_32BIT_MACHINE : 0),
>            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/Object/COFFImportFile.cpp:
> In member function ‘llvm::NewArchiveMember llvm::object::{anonymous}::
> ObjectFactory::createNullThunk(std::vector<unsigned char,
> std::allocator<unsigned char> >&)’:
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/lib/
> Object/COFFImportFile.cpp:390:28: error: enumeral and non-enumeral type
> in conditional expression [-Werror=extra]
>        u16(is32bit(Machine) ? IMAGE_FILE_32BIT_MACHINE : 0),
>            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
>
> The builder was already red and did not send notifications.
> Please have a look?
>
> Thanks
>
> Galina
>
> On Thu, Dec 14, 2017 at 2:07 PM, Zachary Turner via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: zturner
>> Date: Thu Dec 14 14:07:03 2017
>> New Revision: 320750
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=320750&view=rev
>> Log:
>> Fix many -Wsign-compare and -Wtautological-constant-compare warnings.
>>
>> Most of the -Wsign-compare warnings are due to the fact that
>> enums are signed by default in the MS ABI, while the
>> tautological comparison warnings trigger on x86 builds where
>> sizeof(size_t) is 4 bytes, so N > numeric_limits<unsigned>::max()
>> is always false.
>>
>> Differential Revision: https://reviews.llvm.org/D41256
>>
>> Modified:
>>     cfe/trunk/lib/CodeGen/CGExpr.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CG
>> Expr.cpp?rev=320750&r1=320749&r2=320750&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Dec 14 14:07:03 2017
>> @@ -2825,7 +2825,7 @@ void CodeGenFunction::EmitCheck(
>>    assert(IsSanitizerScope);
>>    assert(Checked.size() > 0);
>>    assert(CheckHandler >= 0 &&
>> -         CheckHandler < sizeof(SanitizerHandlers) /
>> sizeof(*SanitizerHandlers));
>> +         size_t(CheckHandler) < llvm::array_lengthof(Sanitizer
>> Handlers));
>>    const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
>>
>>    llvm::Value *FatalCond = nullptr;
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171215/b744f657/attachment-0001.html>


More information about the cfe-commits mailing list