<div dir="ltr"><div>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 ]" <br></div><div><br></div><div>OTOH, the other way around (unsigned -> signed) is implementation-defined. :)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 16, 2016 at 10:27 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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?)</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 15, 2016 at 7:30 PM, George Burgess IV via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gbiv<br>
Date: Wed Jun 15 21:30:33 2016<br>
New Revision: 272867<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272867&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272867&view=rev</a><br>
Log:<br>
[Lex] Try to fix a 'comparison is always false' warning. NFC.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Lex/PPDirectives.cpp<br>
<br>
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=272867&r1=272866&r2=272867&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Jun 15 21:30:33 2016<br>
@@ -162,7 +162,7 @@ static bool warnByDefaultOnWrongCase(Str<br>
   SmallString<32> LowerInclude{Include};<br>
   for (char &Ch : LowerInclude) {<br>
     // In the ASCII range?<br>
-    if (Ch < 0 || Ch > 0x7f)<br>
+    if (static_cast<unsigned char>(Ch) > 0x7f)<br>
       return false; // Can't be a standard header<br>
     // ASCII lowercase:<br>
     if (Ch >= 'A' && Ch <= 'Z')<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>