warnings from use of ctype.h methods
Thu Mar 11 16:28:00 GMT 2010
On 03/11/2010 09:16 AM, Joel Sherrill wrote:
> warning: array subscript has type 'char'
> Most, if not all, of these appear to be from
> using ctype.h methods which is caused by
> a missing (int) case in line 57 in ctype.h:
> #define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[(__c]))[(int)(__c)])
> Changing this to the following resolved the
> #define __ctype_lookup(__c)
> This is with newlib 1.18.0 with the current RTEMS
> Does this cast need to be added?
Absolutely not. The warning is _intentional_. You have a bug in your
code - you are calling the ctype methods with a char argument, but char
is signed, and an 8-bit char is out of range and causes unspecified
results according to the standards. In particular, that warning was
added because we had a demonstration of where isspace(255u) and
isspace(EOF) intentionally give different results in some locales, but
where the calling app had been doing isspace((char)255) and going into
an infinite loop because of their bug. You should fix your code to use
unsigned char or int, as appropriate, in the first place.
Eric Blake firstname.lastname@example.org +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 323 bytes
Desc: OpenPGP digital signature
More information about the Newlib