char array subscript in ctype

Peter Naulls peter at
Sun Dec 30 10:34:26 PST 2001

In message <20011230102327.GB1117 at>
          Vincent Lefevre <vincent at> wrote:

> On Sat, Dec 29, 2001 at 22:50:47 +0000, Ian Jeffray wrote:
> > Peter Naulls wrote:
> > 
> > >When using libscl and certain combinations of warnings, the ctype
> > >isspace, etc. macros may give warnings about subscripts being of type
> > >'char'.
> [snip]
> > Conversely, those functions are documented as taking int's, so it's
> > probably better to fix the code you're compiling, rather than have the
> > compiler/headers hide the issue?  (IE, the headers should do what they
> > say on the tin - which they do right now)
> I completely agree. Using a char as an argument for isspace, etc
> is a bug, in particular when char's are signed (some characters
> may have negative values).

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.

That aside, the real point is that the library headers cause a warning,
which they really shouldn't.  Although Norcroft's defintions are
similar, the compiler itself doesn't issue this warning, which is why
it's not seen.  glibc sets up the functions quite differently so it
doesn't occur with that.


 Peter Naulls - peter at
 RISC OS Projects Initiative  -
 Java for RISC OS and ARM     -
 Debian Linux on RiscPCs      -

More information about the gcc mailing list