[cfe-commits] [PATCH] Enhance -Wtautological-compare
Joerg Sonnenberger
joerg at britannica.bec.de
Fri Mar 2 10:58:20 PST 2012
On Fri, Mar 02, 2012 at 01:45:30PM -0500, Xi Wang wrote:
> 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).
Portable code generally has to deal with "char", i.e. because it is an
interface constraint. Please don't add warnings that triggers on one
platform (which uses unsigned char by default like ARM), but not on
others. I already gave you an instance for code using such checks.
Joerg
More information about the cfe-commits
mailing list