Date: Tue, 30 Nov 1999 23:34:41 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Martin Cracauer <cracauer@cons.org> Cc: arch@freebsd.org Subject: Re: What to do about "subscript has type `char'" warnings? Message-ID: <Pine.BSF.4.10.9911302310430.14878-100000@alphplex.bde.org> In-Reply-To: <19991129230725.B10767@cons.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 29 Nov 1999, Martin Cracauer wrote: > I'd like to point out that the code in question is 100% correct, > because the indexing is guaranteed to be < 128. And >= 0? > I only want to kill the warning, but in the least obscure way and not > killing other warnings that may come up in future. Cast the indexes to int. This is the least obscure way of hinting that the code actually knows what it is doing when it packs small integers into chars. Casting to unsigned char would hint that the range is [0..255] and that the code is too sloppy to use unsigned char for the arrays. Plain char is better than unsigned char if it has adequate range, since it is more likely to be the most efficient char type. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9911302310430.14878-100000>