[PATCH] Add cast in ctype.h macro to avoid gcc -pedantic warning.

Corinna Vinschen vinschen@redhat.com
Thu Feb 20 18:56:00 GMT 2014


On Feb 20 10:32, Sam Clegg wrote:
> Hi newlib,
> 
> A tiny patch to ctype.h.  I found that without this gcc will generate
> a 'array subscript has type ‘char’' warnings when run with -pedantic
> and -Wall.  I found this when compiling libssh which uses -pedandic
> and -pedantic-errors.

This warning has been created deliberatly years ago.  If you're really
pedantic about your code, you should fix it by making sure to cast
signed chars to unsigned char before giving them to the ctype functions.
That's the non-standard behaviour this warning message is supposed to
catch.  See, for instance
http://pubs.opengroup.org/onlinepubs/9699919799/functions/isalpha.html:

"The c argument is an *int*, the value of which the application shall
 ensure is representable as an *unsigned char* or equal to the value
 of the macro EOF. If the argument has any other value, the behavior
 is *undefined*."


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20140220/4ca3d4f3/attachment.sig>


More information about the Newlib mailing list