[cfe-commits] [PATCH] Enhance -Wtautological-compare

Xi Wang xi.wang at gmail.com
Fri Mar 2 10:45:30 PST 2012


On Mar 2, 2012, at 12:52 PM, Joerg Sonnenberger wrote:
> 
> That's my point. Warning about char being checked for being < 0 can be
> found a lot in portable code. It is not automatically tautological, so I
> don't think it should trigger the check.

I don't think the code is "portable" in that case.  If plain char
is treated as unsigned (e.g., invoking clang with -funsigned-char
or on platforms that treat plain char as unsigned), then the check
(char < 0) is a tautological comparison that we should warn against
--- the disabled check is almost always a logic bug.  Portable code
should use (signed char < 0).

- xi




More information about the cfe-commits mailing list