Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Oct 2000 23:26:20 +0200
From:      "Leif Neland" <leifn@neland.dk>
Cc:        <hackers@FreeBSD.ORG>
Subject:   Re: Question about -Wchar-subscripts
Message-ID:  <00bf01c02d81$17f90240$0e00a8c0@neland.dk>
References:  <Pine.BSF.4.05.10010031536460.75472-100000@heathers.stdio.com> <20001003144911.A12803@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help

----- Original Message -----
From: "Dan Nelson" <dnelson@emsphone.com>
To: "Larry Lile" <lile@stdio.com>
Cc: <hackers@FreeBSD.ORG>
Sent: Tuesday, October 03, 2000 9:49 PM
Subject: Re: Question about -Wchar-subscripts


> In the last episode (Oct 03), Larry Lile said:
> >
> >     ...we get scores of warnings about using characters as subscripts
> >     to an array (-Wchar-subscripts), which generates so much noise as
> >     to mask real warnings burried within. Therefore, I would like to
> >     suppress this warning unless someone can explain why using a char
> >     as an array subscript is in any way an illegitimate thing to do.
> >     As far as I can tell, getting rid of the warning by changing the
> >     code would require adding a large number of frivolous casts to
> >     scores of source files...
> >
> > So why is using a "char" as an array subscript wrong?  I had always
> > avoided it because the compiler complained and that was good enough
> > for me.
>
> Because your char value could be negative and end up referencing memory
> before your array start.  Mainly a problem with the ctype macros and
> high-ascii characters.
>
How about unsigned char? Could that be used for index?

Leif




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00bf01c02d81$17f90240$0e00a8c0>