char array subscript in ctype
ian at jeffray.co.uk
Mon Dec 31 03:59:54 PST 2001
Peter Naulls wrote:
> While no doubt warnings are very useful, I fear that the one produced in
> this case is somewhat confusing, especially to a novice programmer
> (lclint might throw up something more useful); I spent quite sometime
> working out what exactly was generating the warning.
I really don't understand what you're saying here. The compiler produces
a warning about an incorrect type. You examine your code, note that
isalpha() and friends want an int but you're giving it a char or somesuch,
so you cast it in *your application code* and all is fixed.
I can't see what's really confusing about this particular warning as opposed
to any other warning the compiler generates, personally.
To be honest, I might be more worried about gcc if it had not produced a
In conclusion to this thread (maybe? :) there is a simple choice - put the
casts in these #defines to make the compiler quietly accept any garbage
parameter (eg even a (char *)) to isalpha() and friends, or leave it as is
and have some warning when the user has written poor code. IMO the choice
Goodbye 2001. Happy Hogmanay all.
More information about the gcc