From: Keir Fraser Subject: Re: [PATCH] libfsimage: Make it build on NetBSD Date: Sun, 23 Sep 2007 14:44:50 +0100 Message-ID: References: <20070923125502.GA14313@wavehammer.waldi.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20070923125502.GA14313@wavehammer.waldi.eu.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Bastian Blank Cc: Christoph Egger , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 23/9/07 13:55, "Bastian Blank" wrote: >> If we sensibly take 'representable' to mean 'representable with the same >> integer value', then the casts are clearly needed for compliance. >=20 > No. 'representable' means that the value fits in unsigned char (0-255 on > common systems). See example 6 of =A75.1.2.3 how the standard uses > representable. A cast would force that, if you use unsigned char. Well, actually that's what I meant but may have worded poorly. Yes, the range of an unsigned char is [0, 255] and hence no negative integer can be represented. So passing a negative char to a ctype function is invalid. >> And read glibc's ctype.h -- it goes to some effort to support 'signed ch= ar' >> input, but makes it clear this is "for broken old programs". >=20 > Yeah, it explicitely does the change which the explicite conversion to > unsigned char would do. Actually it casts to int, at least in my installed glibc. Thus the sign is maintained, and allowance is made by glibc for negative indexing into its ctype array. I interpret this as a kludge to let old programs and lazy programmers do the obvious thing in spite of the spec. -- Keir