This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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 > warnings. > > #define __ctype_lookup(__c) > ((__ctype_ptr__+sizeof(""[(int)__c]))[(int)(__c)]) > > This is with newlib 1.18.0 with the current RTEMS > patch. > > 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 eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |