This is the mail archive of the
mailing list for the GCC project.
Re: egcs, warning patch for missing initializers in xsys-protos.h
- To: egcs-patches at cygnus dot com, rth at cygnus dot com
- Subject: Re: egcs, warning patch for missing initializers in xsys-protos.h
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sat, 19 Sep 1998 09:01:55 -0400 (EDT)
> From: Richard Henderson <firstname.lastname@example.org>
> On Wed, Sep 16, 1998 at 10:42:24AM -0400, Kaveh R. Ghazi wrote:
> > - if (!ISALNUM (*ptr))
> > + if (!ISALNUM ((unsigned char)*ptr))
> If this needs doing, why isn't it done in ISALNUM?
> In any case, isalnum normally takes an int, since isalnum(EOF)
> is defined.
IMHO, you can't safely cast ctype function arguments in the
ctype macros. This was partially discussed last February starting with:
http://www.cygnus.com/ml/egcs/1998-Feb/0643.html. It became clear, in
that discussion, that casting to int was bad. The warning is pointing
out something valid, the fact that char is often signed and when you
evaluate character values > 127, you get negative results. Ctype macros
are often defined as lookups in an array, thus the negative index is
However, I wasn't satisfied with the direction of that
discussion which seemed to endorse casting >>in the macro definition<<
to unsigned char, because as you note above it fails to properly
The only solution appears to be fixing the source code at the
*site* of each call. If its already an int, no fix is needed. If the
type is a char, you can safely cast it to unsigned char because
supposedly you are already assuming that EOF is not in play.
Kaveh R. Ghazi Engagement Manager / Project Services
email@example.com Icon CMT Corp.