tautological-compare for unsigned chars

Hi,

Am I right in thinking that char types are not checked for tautological-compare?

I started to look at SemaChecking.cpp CheckTrivialUnsignedComparison()
Is this the right place?

example code:
void test(void) {
unsigned char c = (unsigned char)-1;
if(c >= 0) test();
unsigned int i = (unsigned int)-1;
if(i >= 0) test();
}
gives the warning:
char_signedness.c:6:8: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
if(i >= 0) test();
~ ^ ~
1 warning generated.

I’m happy to do the work, but would welcome some input!

robert

Am I right in thinking that char types are not checked for tautological-compare?

Certainly looks like it, but not through any active choice I think:

      unsigned char c = (unsigned char)-1;
      if(c >= 0) test();

This comparison is actually signed after the usual arithmetic
conversions have kicked in. An implicit cast is inserted making it
roughly "if ((int)c >= 0)".

It looks like code could be added to AnalyzeComparison to deal with
this case. CheckTrivialUnsignedComparison can probably do the right
thing already *if* it gets called.

Tim.