This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: signed vs unsigned pointer warning


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]