This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs, warning patch for missing initializers in xsys-protos.h


On Sat, Sep 19, 1998 at 09:01:55AM -0400, Kaveh R. Ghazi wrote:
> 	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.

What I see in that thread are a lot of what-ifs.  I ask those
involved the last time round: are there any actual systems that
display actual problems?

> 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
> bogus. 

Not necessarily.  For instance glibc defines things like this

	static unsigned short ctype_b[128+256] = {...}
	unsigned short *__ctype_b = &ctype_b[128];

which means that negative values do work.  Do actual implementations
really get this wrong?  Virtually all systems define EOF as -1 and
so must do something like this anyway.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]