From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21783 invoked by alias); 8 Oct 2004 17:12:33 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 21776 invoked from network); 8 Oct 2004 17:12:32 -0000 Received: from unknown (HELO NUTMEG.CAM.ARTIMI.COM) (217.40.111.177) by sourceware.org with SMTP; 8 Oct 2004 17:12:32 -0000 Received: from mace ([192.168.1.25]) by NUTMEG.CAM.ARTIMI.COM with Microsoft SMTPSVC(6.0.3790.0); Fri, 8 Oct 2004 18:12:09 +0100 From: "Dave Korn" To: "'Joe Buck'" , "'Nick Ing-Simmons'" , , , "'Morten Welinder'" Subject: RE: signed vs unsigned pointer warning Date: Fri, 08 Oct 2004 18:15:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <20041008100853.A2207@synopsys.com> Message-ID: X-OriginalArrivalTime: 08 Oct 2004 17:12:09.0329 (UTC) FILETIME=[F1C76E10:01C4AD59] X-SW-Source: 2004-10/txt/msg00363.txt.bz2 > -----Original Message----- > From: Joe Buck > Sent: 08 October 2004 18:09 > To: Nick Ing-Simmons; jamie@shareable.org; gcc@gcc.gnu.org; > 'Morten Welinder'; Dave Korn > Subject: Re: signed vs unsigned pointer warning > > On Fri, Oct 08, 2004 at 12:26:35PM -0400, Paul Jarc wrote: > > Joe Buck wrote: > > > Why can't an implementation define isxxx(c) to return > something like > > > table_lookup[(unsigned)(c)] > > > ? > > > > Assuming EOF==-1, that fails to distinguish between EOF and > character > > 255 (as does the 384-element table in the case where a > signed char is > > passed). The ctype macros are supposed to accept EOF as well as > > unsigned char values. > > No, (unsigned)-1 does not turn into 255, it turns into a very large > number. You cannot store EOF in a char. Of course, isXXXX functions do take an int argument, which can indeed store EOF. > Here's a bug fix: > > table_lookup[1U+(unsigned)(c)] > > Now EOF goes into slot 0. Hmm, but only by virtue of integer maths overflow. Wouldn't it be better to just leave out the cast in this case and do the sum in signed math? cheers, DaveK -- Can't think of a witty .sigline today....