[cfe-commits] [PATCH] Improve -Wtautological-constant-out-of-range-compare

Eli Friedman eli.friedman at gmail.com
Wed Nov 14 12:16:57 PST 2012


  +  // Common unsigned, other signed, constant unsigned
  +  (void)((int)other != (unsigned long)(0xffffffffffffffff)); //
  expected-warning{{different signs}}
  +  (void)((int)other != (unsigned long)(0x00000000ffffffff)); //
  expected-warning{{true}}

  I'd like to see a testcase for (int)other < (unsigned long)(0x00000000ffffffff).

  +      // The constant value rests between values that OtherT can
  represent after
  +      // conversion.  Relational comparison still works, but equality
  +      // comparisons will be tautological.
  +      if (OtherWidth <= Value.getActiveBits())
  +        EqualityOnly = true;

  The condition of this branch is always true.


  I think I've run out of comments now. :)  (I know it must be annoying
  to take this many rounds to review this, but thanks for sticking with
  it.)

  -Eli

http://llvm-reviews.chandlerc.com/D113



More information about the cfe-commits mailing list