svn commit: r298924 - head/usr.bin/sdiff

Benjamin Kaduk kaduk at MIT.EDU
Mon May 2 16:19:29 UTC 2016


On Mon, 2 May 2016, Bjoern A. Zeeb wrote:

>
> > On 02 May 2016, at 16:08 , Conrad Meyer <cem at FreeBSD.org> wrote:
> >
> > On Mon, May 2, 2016 at 8:57 AM, Benjamin Kaduk <bjkfbsd at gmail.com> wrote:
> >> On Mon, May 2, 2016 at 10:54 AM, Bjoern A. Zeeb <bz at freebsd.org> wrote:
> >>>> On 02 May 2016, at 15:32 , Conrad Meyer <cem at FreeBSD.org> wrote:
> >>>>
> >>>> Clang should really catch this too.  Why didn’t it?
> >>>
> >>> It was only powerpc;  sparc64 and mips were good as well.
> >>
> >> 'char' being signed vs. unsigned?
> >
> > Yeah, that occurred to me, but EOF should be out of range for any char
> > type.  I'd like ((char)getchar() == EOF) to warn on all platforms.
>
> I think we just define EOF to be -1.  Someone should check, and that the warning message might be misleading.

Yeah, stdio.h has:

#define EOF     (-1)

If char is signed, that gets more exciting, due to the value-preserving
promotion rule (after the char cast, it gets converted back to int for the
comparison operation).

Also, -1 is assumed to be EOF in external code, e.g.,
contrib/top/getopt.c.

-Ben


More information about the svn-src-all mailing list