This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: signed vs unsigned pointer warning
- From: "Dave Korn" <dk at artimi dot com>
- To: "'Nick Ing-Simmons'" <nick at ing-simmons dot net>,<jamie at shareable dot org>
- Cc: <gcc at gcc dot gnu dot org>,"'Morten Welinder'" <terra at gnome dot org>
- Date: Fri, 8 Oct 2004 14:12:56 +0100
- Subject: RE: signed vs unsigned pointer warning
> -----Original Message-----
> From: Nick Ing-Simmons [mailto:nick@ing-simmons.net]
> Sent: 08 October 2004 14:06
> >This is a real typical bug. Just recently a bug was found in
> >curl-library, quite a popular little library, which calls
> >isspace(char). The bug was missed for a long time, as it is only
> >triggered with characters with the MSB set, which do not occur often
> >in HTTP headers.
>
> I am reasnably sure that on old SunOS4 systems passing signed char
> to isxxx() was normal and worked. The lookup tables where defined
> in such a way that 128 or so entries before the normal table
> replicated
> the 2nd half.
>
> Snag is it is hard to define such arrays in C.
Well, you don't, you just define a "type * const" pointer to the 128'th
entry of the real underlying, e.g. instead of saying
unsigned char isXXX_flags_array[256]
you say
static unsigned char __isXXX_flags_array[256];
unsigned char * const isXXX_flags_array = &__is_flags_array[128];
Or at any rate, I use that idiom quite a lot.
cheers,
DaveK
--
Can't think of a witty .sigline today....