From owner-freebsd-arch Tue Nov 30 4:35:34 1999 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id 2337415150 for ; Tue, 30 Nov 1999 04:35:31 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id NAA04769 for ; Tue, 30 Nov 1999 13:35:30 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id NAA70007 for freebsd-arch@freebsd.org; Tue, 30 Nov 1999 13:35:29 +0100 (MET) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id C981115150 for ; Tue, 30 Nov 1999 04:35:03 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (beefcake.zeta.org.au [203.26.10.12]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id XAA23448; Tue, 30 Nov 1999 23:43:02 +1100 Date: Tue, 30 Nov 1999 23:34:41 +1100 (EST) From: Bruce Evans X-Sender: bde@alphplex.bde.org To: Martin Cracauer Cc: arch@freebsd.org Subject: Re: What to do about "subscript has type `char'" warnings? In-Reply-To: <19991129230725.B10767@cons.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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