From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9064 invoked by alias); 8 Oct 2004 18:57:04 -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 9048 invoked from network); 8 Oct 2004 18:57:02 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.184) by sourceware.org with SMTP; 8 Oct 2004 18:57:02 -0000 Received: from [212.227.126.206] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1CFzvK-0005Ur-00 for gcc@gcc.gnu.org; Fri, 08 Oct 2004 20:57:02 +0200 Received: from [84.135.62.233] (helo=buddha.localdomain.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1CFzvJ-0005JM-00 for gcc@gcc.gnu.org; Fri, 08 Oct 2004 20:57:01 +0200 Date: Fri, 08 Oct 2004 20:59:00 -0000 From: "Matthias B." To: gcc@gcc.gnu.org Subject: Re: signed vs unsigned pointer warning Message-Id: <20041008205704.512ab964@buddha.localdomain.de> In-Reply-To: <20041008173153.E89761422D56@darter.rentec.com> References: <20040922161751.B4F6A1422D53@darter.rentec.com> <20040926192142.GA29842@mail.shareable.org> <20040926192142.GA29842@mail.shareable.org> <20041008130623.9516.4@llama.elixent.com> <20041008091714.A1695@synopsys.com> <20041008173153.E89761422D56@darter.rentec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:95d11223a40b7ac6df081cef1fe1fef2 X-SW-Source: 2004-10/txt/msg00371.txt.bz2 On Fri, 8 Oct 2004 13:31:53 -0400 (EDT) terra@gnome.org (Morten Welinder) wrote: > > Why can't an implementation define isxxx(c) to return something like > table_lookup[(unsigned)(c)] > ? > > Because isxxx needs to work with EOF, typically -1. So what? On my system all the is* calls return the same thing for EOF as they do for 255, namely 0. Is there an actual locale where any of the is*() calls returns non-zero for 255? In any case, for the usual western locales, your argument is invalid. > And regardless of the implementation's value of EOF, you cannot cast to > "unsigned char" either because that would make EOF collide with one of > the other 256 valid inputs. > > So to summarize: someone screwed up with the definition of isxxx and it > is not fixable by the implementation. Therefore, get used to seeing > code like > > const char *foo = whatever; > if (isspace ((unsigned char)*foo)) oink (); > > no matter how ugly it is. I've grepped through a couple sources I had lying around. I don't think we'll have to get used to this anytime soon. Almost everyone just seems to pass signed chars to the is* functions. It's the DE FACTO standard and libraries/compilers better implement it. And as stated above, for the usual western locales, you can implement it without violating the standard, so not supporting signed char arguments would be completely irrational. MSB -- You know that you're lonely when you start laughing at your own jokes.