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: Joe dot Buck at synopsys dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 8 Oct 2004 13:31:53 -0400 (EDT)
- Subject: Re: signed vs unsigned pointer warning
- References: <20040922161751.B4F6A1422D53@darter.rentec.com><NUTMEGODkUqESudbgsy00000021@NUTMEG.CAM.ARTIMI.COM><20040926192142.GA29842@mail.shareable.org> <20040926192142.GA29842@mail.shareable.org> <20041008130623.9516.4@llama.elixent.com> <20041008091714.A1695@synopsys.com>
Why can't an implementation define isxxx(c) to return something like
table_lookup[(unsigned)(c)]
?
Because isxxx needs to work with EOF, typically -1.
And regardless of the implementation's value of EOF, you cannot cast to
"unsigned char" either because that would make EOF collide with one of
the other 256 valid inputs.
So to summarize: someone screwed up with the definition of isxxx and it
is not fixable by the implementation. Therefore, get used to seeing
code like
const char *foo = whatever;
if (isspace ((unsigned char)*foo)) oink ();
no matter how ugly it is.
Morten