Fwd: Newlib's implementation of isalnum() is causing compiler warnings
Rafal Zwierz
rzwierz@googlemail.com
Mon Nov 14 11:16:00 GMT 2011
Hi,
First of all apologies if it is not the right place to submit patches
for newlib/libc used by cygwin. If it's not then I would appreciate if
you could point me to the right place for submitting such patches.
If it is the right place then please read on.
main.c (attached) is a simple app which, when compiled with under Cygwin
gcc -Wall -Werror main.c
shows the following problem:
cc1: warnings being treated as errors
main.c: In function ‘main’:
main.c:6:4: error: array subscript has type ‘char’
The fix is quite simple and is contained in patch.txt.
Best wishes,
Rafal
-------------- next part --------------
--- ctype_orig.h 2009-11-07 15:25:20.000000000 +0000
+++ ctype.h 2011-11-14 10:58:39.108899500 +0000
@@ -54,7 +54,7 @@ extern __IMPORT char *__ctype_ptr__;
Meanwhile, the real index to __ctype_ptr__+1 must be cast to int,
since isalpha(0x100000001LL) must equal isalpha(1), rather than being
an out-of-bounds reference on a 64-bit machine. */
-#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
+#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[(int)(__c)]))[(int)(__c)])
#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L))
#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 74 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20111114/db8618a3/attachment.bin>
More information about the Cygwin-patches
mailing list