public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Matthias B." <msbREMOVE-THIS@winterdrache.de>
To: gcc@gcc.gnu.org
Subject: Re: signed vs unsigned pointer warning
Date: Fri, 08 Oct 2004 20:59:00 -0000	[thread overview]
Message-ID: <20041008205704.512ab964@buddha.localdomain.de> (raw)
In-Reply-To: <20041008173153.E89761422D56@darter.rentec.com>

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.

  reply	other threads:[~2004-10-08 18:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22 16:43 Morten Welinder
2004-09-22 17:17 ` Paul Koning
2004-09-22 17:27   ` Morten Welinder
2004-09-22 17:49     ` Dave Korn
2004-09-22 17:20 ` Dave Korn
2004-09-23  1:31   ` Andreas Schwab
2004-09-23 12:29     ` Dave Korn
2004-09-23 18:57       ` Joe Buck
2004-09-23 19:38         ` Dave Korn
2004-09-27  2:04   ` Jamie Lokier
2004-10-08 13:29     ` Nick Ing-Simmons
2004-10-08 13:32       ` Dave Korn
2004-10-08 17:20       ` Joe Buck
2004-10-08 17:28         ` Paul Jarc
2004-10-08 17:59           ` Joe Buck
2004-10-08 18:15             ` Dave Korn
2004-10-08 18:22               ` Joe Buck
2004-10-08 18:24             ` Jamie Lokier
2004-10-08 19:57             ` Paul Jarc
2004-10-09  7:05               ` Jamie Lokier
2004-10-09  8:48                 ` Paul Jarc
2004-10-11 16:34                   ` Richard Earnshaw
2004-10-08 18:57         ` Morten Welinder
2004-10-08 20:59           ` Matthias B. [this message]
2004-10-08 22:34             ` Paul Koning
2004-10-10  2:03               ` Matthias B.
2004-10-09  1:39             ` Andreas Schwab
2004-10-11  0:11           ` Kai Henningsen
  -- strict thread matches above, loose matches on Subject: below --
2004-09-21 20:52 Richard Henderson
2004-09-21 22:36 ` Linus Torvalds
2004-09-22 14:35   ` Dave Korn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041008205704.512ab964@buddha.localdomain.de \
    --to=msbremove-this@winterdrache.de \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).