This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11435] <ctype.h> inhibits -Wchar-subscript warning on invalid use of character classification macros
- From: "bart dot vanassche at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 26 Mar 2010 12:00:26 -0000
- Subject: [Bug libc/11435] <ctype.h> inhibits -Wchar-subscript warning on invalid use of character classification macros
- References: <20100326114608.11435.bart.vanassche@gmail.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From bart dot vanassche at gmail dot com 2010-03-26 12:00 -------
See also http://sourceware.org/git/?p=glibc.git;a=blob;f=ctype/ctype.h;hb=HEAD
Note: Cygwin's <ctype.h> header file contains the following comment:
/* These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'. Note that the sizeof will
always be 1, which is what we want for mapping EOF to __ctype_ptr__[0];
the use of a raw index inside the sizeof triggers the gcc warning if
__c was of type char, and sizeof masks side effects of the extra __c.
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)])
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11435
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.