[cfe-commits] [PATCH] Enhance -Wtautological-compare
Joerg Sonnenberger
joerg at britannica.bec.de
Fri Mar 2 11:31:52 PST 2012
On Fri, Mar 02, 2012 at 02:08:26PM -0500, Xi Wang wrote:
> On Mar 2, 2012, at 1:58 PM, Joerg Sonnenberger wrote:
> > 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.
>
> Do you mean some ctype.h implementation? Can you please point me to an
> example where (char < 0) is used and char is unsigned? Thanks. ;-)
Consider
#define isalpha(x) ((x) == EOF ? 0 : ctab[(unsigned char)(x)] & ALPHA_MASK)
Modulo evaluating (x) twice, that's a generic implemenation of isalpha,
given a bit table ctab with the appropiate mask.
Given an argument of type char, this turns effectively into a check char
== -1, which is tautological on ARM.
Joerg
More information about the cfe-commits
mailing list