Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 03 May 2003 08:29:58 -0400
From:      "Louis A. Mamakos" <louie@TransSys.COM>
To:        "Jacques A. Vidrine" <nectar@freebsd.org>
Cc:        Dag-Erling Smorgrav <des@ofug.org>
Subject:   Re: incorrect enum warning? 
Message-ID:  <200305031229.h43CTw1L067503@whizzo.transsys.com>
In-Reply-To: Your message of "Thu, 01 May 2003 10:07:13 CDT." <20030501150713.GA34992@madman.celabo.org> 
References:  <xzp7k9a67pf.fsf@flood.ping.uio.no> <20030501150713.GA34992@madman.celabo.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> On Thu, May 01, 2003 at 04:51:40PM +0200, Dag-Erling Smorgrav wrote:
> > Why does the following code in OpenPAM headers:
> > 
> > /*
> >  * XSSO 5.4
> >  */
> > enum {
> >         PAM_SILENT                      = 0x80000000,
> >         PAM_DISALLOW_NULL_AUTHTOK       = 0x1,
> >         PAM_ESTABLISH_CRED              = 0x1,
> >         PAM_DELETE_CRED                 = 0x2,
> >         PAM_REINITIALIZE_CRED           = 0x4,
> >         PAM_REFRESH_CRED                = 0x8,
> >         PAM_PRELIM_CHECK                = 0x1,
> >         PAM_UPDATE_AUTHTOK              = 0x2,
> >         PAM_CHANGE_EXPIRED_AUTHTOK      = 0x4
> > };
> > 
> > cause the following warning when compiled with CSTD=c99:
> > 
> > /usr/src/contrib/openpam/include/security/pam_constants.h:100: warning: ISO C restricts enumerator values to range of `int'
> > 
> > when 0x80000000 is clearly within the range of 'int' on all platforms
> > we support?
> 
> Guessing:
> C does not specify one's complement or two's complement representation
> of integers.  On a one's complement 32-bit platform, 0x80000000 is -0
> (negative zero), which cannot be an `int'.

That's incorrect; on a 32-bit 1's complement CPU, 0xffffffff is -0.   You're
thinking of the signed magnitude representation.

louie

>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305031229.h43CTw1L067503>