signed vs unsigned pointer warning

Jamie Lokier jamie@shareable.org
Fri Oct 8 18:24:00 GMT 2004


Joe Buck wrote:
> No, (unsigned)-1 does not turn into 255, it turns into a very large
> number.  You cannot store EOF in a char.  Here's a bug fix:
> 
> 	 table_lookup[1U+(unsigned)(c)]
> 
> Now EOF goes into slot 0.

The trouble is that char 255 (or char -1 depending on your point of
view) _might_ also go into slot 0, depending on the type of c and how
it was passed.

Do the standards require anything about the result of is*(EOF), or do
the functions simply have to accept that as an argument?

In any case, code which writes:

    char c = ... ;
    ...
    if (isspace(c)) {
        ...
    }

Surely deserves a warning from the compiler, just because it'll fail
on some OSes.

-- Jamie



More information about the Gcc mailing list