[PATCH] D39149: [libc++] Prevent tautological comparisons

Brian Cain via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 10:53:12 PDT 2017


bcain added a comment.

In https://reviews.llvm.org/D39149#910845, @lebedev.ri wrote:

> That is my diagnostic, so i guess this is the time to reply :)


...

> 3. In `-Wtautological-constant-compare`, ignore any comparisons that compare with `std::numeric_limits`. Not a fan of this solution. <- Worst?

...

Gee, #3 is the worst?  That one seems the most appealing to me.  I think I could understand it if you had reservations about ignoring comparisons against {CHAR,SHRT,INT,LONG}_{MIN,MAX} but std::numeric_limits is well-qualified and everything.

Can you help me understand why you don't prefer it?

Also, is there any way that the warning could somehow be smart enough to know what sizeof(int) and sizeof(long) are?

As an aside, how widely has this new clang behavior been tested?  Is it possible that this new warning behavior might get rolled back if a big/important enough codebase triggers it?


https://reviews.llvm.org/D39149





More information about the cfe-commits mailing list