This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wimplicit-signed-char
- To: schwab at suse dot de (Andreas Schwab)
- Subject: Re: -Wimplicit-signed-char
- From: Russell King <rmk at arm dot linux dot org dot uk>
- Date: Wed, 10 May 2000 21:23:59 +0100 (BST)
- Cc: jamie dot lokier at cern dot ch (Jamie Lokier), gcc at gcc dot gnu dot org, philb at gnu dot org
Andreas Schwab writes:
> Jamie Lokier <jamie.lokier@cern.ch> writes:
> |> Russell King wrote:
> |> > char ch;
> |> > do {
> |> > ch = getopt(...);
> |> > ...
> |> > } while (ch != EOF);
> |> >
> |> > The above fragments of code compile cleanly on architectures which default
> |> > to signed chars.
> |>
> |> However, the EOF fragment is broken whatever the signedness :-)
> |> Use `int ch'.
>
> Moreover, getopt does not actually return EOF, but -1.
Correct, so the above is broken for more reasons than just the 'char'
part.
The only reason it happens to work is because of an implementation chose
the value "-1" to mean EOF.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |