char array subscript in ctype

Vincent Lefevre vincent at vinc17.org
Mon Dec 31 01:46:50 PST 2001


On Mon, Dec 31, 2001 at 06:27:33 +0000, Peter Naulls wrote:
> In message <3C2FB10F.7040105 at jeffray.co.uk>
>           Ian Jeffray <ian at jeffray.co.uk> wrote:
> 
> > Peter Naulls wrote:
> > 
> > > I'm not sure that's a valid argument.  isspace and friends are almost
> > > always used in the context of unqualified chars (unsigned on ARM, signed
> > > on x86).   Futhermore, the specification for these functions says that
> > > the integer passed is interpreted as an unsigned char (or EOF).  The
> > > cast to unsigned int ensures this.
> > 
> > 
> > Not really... the cast "ensures" that you _don't_ know when you've
> > written some crap code.
> 
> No, I'm just quoting common usage and what the defintion of these
> functions say.

Common usage is to pass either an int or an unsigned char.

The standard says that the value passed to these function must be
either EOF or a value representable as an unsigned char. In the
first case, your cast will break things, and in the second case,
your cast is useless (and may hide warnings).

-- 
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International des
Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



More information about the gcc mailing list