This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: signed vs unsigned pointer warning
- From: prj at po dot cwru dot edu (Paul Jarc)
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: Nick Ing-Simmons <nick at ing-simmons dot net>, jamie at shareable dot org, gcc at gcc dot gnu dot org, "'Morten Welinder'" <terra at gnome dot org>, Dave Korn <dk at artimi dot com>
- Date: Fri, 08 Oct 2004 13:57:32 -0400
- Subject: Re: signed vs unsigned pointer warning
- Organization: What did you have in mind? A short, blunt, human pyramid?
- References: <20040922161751.B4F6A1422D53@darter.rentec.com><NUTMEGODkUqESudbgsy00000021@NUTMEG.CAM.ARTIMI.COM><20040926192142.GA29842@mail.shareable.org><20040926192142.GA29842@mail.shareable.org><20041008130623.9516.4@llama.elixent.com><20041008091714.A1695@synopsys.com> <m3d5zttbu6.fsf@multivac.cwru.edu><20041008100853.A2207@synopsys.com>
Joe Buck <Joe.Buck@synopsys.COM> wrote:
> No, (unsigned)-1 does not turn into 255, it turns into a very large
> number.
But character 255, as a signed char, is also -1, and so will also
become the same large number. The caller must cast char to unsigned
char to ensure that EOF is distinct. *Only* the caller can make the
distinction reliably, since only the caller knows whether this
particular -1 is supposed to be EOF.
paul