[cfe-dev] tautological-compare for unsigned chars

Robert Lytton robert at xmos.com
Tue Jul 30 10:24:21 PDT 2013


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130730/43e80038/attachment.html>


More information about the cfe-dev mailing list