[PATCH] Disable specific MSVC warnings so that W4 warnings can be enabled.

Aaron Ballman aaron at aaronballman.com
Tue Mar 24 12:36:34 PDT 2015


On Tue, Mar 24, 2015 at 2:42 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Tue, Mar 24, 2015 at 11:29 AM, Andy Kaylor <andrew.kaylor at intel.com>
> wrote:
>>
>> REPOSITORY
>>   rL LLVM
>>
>> ================
>> Comment at: cmake/modules/HandleLLVMOptions.cmake:286
>> @@ +285,3 @@
>> +    -wd4706 # Suppress 'assignment within conditional expression'
>> +    -wd4310 # Suppress 'cast truncates constant value'
>> +    -wd4701 # Suppress 'potentially uninitialized local variable'
>> ----------------
>> dblaikie wrote:
>> > You mentioned this one fired ~200 times - this might actually be worth
>> > doing a small sample check to see what it's firing on. Perhaps these are
>> > things we should fix - unless they appear in dependent expressions in
>> > templates, in which case they're probably false positives.
>> >
>> > The rest of these disables I'm totally fine with - if you want, please
>> > commit them separately/ahead of the rest of the review.
>> These look pretty harmless.  All of the ones I looked at were something
>> like these:
>>
>> ```
>> uint8_t(~0U)
>> (char)0xFF
>> (uint16_t)-1U
>
>
> Yeah, those all look like they do exactly what the user intended... I wonder
> if MSVC expects those to be written some other way? *shrug*

MSVC is very picky about the way you write unsigned values like that.
~0U is about the only way to get it to not complain (aside from
spelling out the full bit pattern). We do run into this fairly
frequently in practice.

~Aaron



More information about the llvm-commits mailing list