This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: signed vs unsigned pointer warning
- From: terra at gnome dot org (Morten Welinder)
- To: gcc at gcc dot gnu dot org
- Cc: dk at artimi dot com
- Date: Wed, 22 Sep 2004 12:17:51 -0400 (EDT)
- Subject: RE: signed vs unsigned pointer warning
Dave Korn writes:
> Until you try indexing an array with an 8-bit high ASCII char, of course.
> Then things become radically different. I've known buggy ctype
> implementations that have failed on this (ASCII > 127 being signed negative
> and the ctype function accidentally indexing memory space before an array
> full of ctype result flags).
[/me gathers soapbox]
I bet you have. In fact *ALL* ctype implementations will fail.[*]
That includes glibc
What glibc does is to *mostly* work around buggy programs that send
(explicitly or implicitly) signed characters to, say, isprint. It does
not always work, though, so glibc really did you a disservice. It is
really hard to get people to fix their programs.
It does not work for (signed char)-1 if EOF==-1. It cannot work as two
different results are required for the same argument value.
Solaris does the array[arg] thing you speak about. It isn't buggy. The
caller is, and, IMHO the standard is.
Morten
[*] Assuming (char)EOF==EOF, which it will be with signed characters and
EOF==-1.