r272867 - [Lex] Try to fix a 'comparison is always false' warning. NFC.
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 16 10:44:11 PDT 2016
I don't think so -- 4.7p2 says "If the destination type is unsigned, the
resulting value is the least unsigned integer congruent to the source
integer (modulo 2 n where n is the number of bits used to represent the
unsigned type). [ Note: In a two’s complement representation, this
conversion is conceptual and there is no change in the bit pattern (if
there is no truncation). — end note ]"
OTOH, the other way around (unsigned -> signed) is implementation-defined.
:)
On Thu, Jun 16, 2016 at 10:27 AM, David Blaikie <dblaikie at gmail.com> wrote:
> I can't remember the rules - but wouldn't this produce UB on a signed char
> platform in the case where Ch is negative? (or is that just unspecified?
> implementation defined?)
>
> On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: gbiv
>> Date: Wed Jun 15 21:30:33 2016
>> New Revision: 272867
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272867&view=rev
>> Log:
>> [Lex] Try to fix a 'comparison is always false' warning. NFC.
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPDirectives.cpp
>>
>> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016
>> @@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str
>> SmallString<32> LowerInclude{Include};
>> for (char &Ch : LowerInclude) {
>> // In the ASCII range?
>> - if (Ch < 0 || Ch > 0x7f)
>> + if (static_cast<unsigned char>(Ch) > 0x7f)
>> return false; // Can't be a standard header
>> // ASCII lowercase:
>> if (Ch >= 'A' && Ch <= 'Z')
>>
>>
>> _______________________________________________
>> 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/20160616/f6b6d86e/attachment-0001.html>
More information about the cfe-commits
mailing list