Subject: Re: gcc-current and warnings in bin/sh
To: David Laight <david@l8s.co.uk>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 06/05/2002 22:52:40
On Wed, 5 Jun 2002, David Laight wrote:

> On Fri, May 31, 2002 at 07:16:01PM +0100, Ben Harris wrote:
> > In article <GwzK2v.H4E@tac.nyc.ny.us> you write:
> > >for systems with signed chars this ended up being
> > >
> > >#define UPEOF -129
> > >
> > >which is out of range for char. (it has been fixed)
> >
> > Ah.  I hadn't noticed the strange dance being done with "base" in the signed
> > case.
>
> Because it isn't! dunno where -129 might come from!

The "strange dance" I meant was:

        base = 1;
        if (sign)
                base += 1 << (nbits - 1);

If nbits == 8 and sign == 1, you get base == 129, so this:

        if (sign)
                fprintf(hfile, "#define UPEOF %d\n\n", -base);
        else
                fprintf(hfile, "#define UPEOF ((unsigned char) %d)\n\n", -base);

... will define UPEOF to -129, which is what was causing the problem.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>