Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jul 2003 13:37:32 -0500
From:      David Leimbach <leimy2k@mac.com>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        jilles@stack.nl
Subject:   Re: GCC 3.3.1, new warnings with <limits>
Message-ID:  <1046B4F9-B561-11D7-BE3B-0003937E39E0@mac.com>
In-Reply-To: <20030713.122352.22176834.imp@bsdimp.com>
References:  <20030713000559.28c18be6.kabaev@mail.ru> <20030713044331.GA89785@crodrigues.org> <20030713152154.GA96653@stack.nl> <20030713.122352.22176834.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sunday, July 13, 2003, at 1:23PM, M. Warner Losh wrote:

> : >     134 #define __glibcpp_signed(T)     ((T)(-1) < 0)
> : #define __glibcpp_signed(T)     (!((T)(-1) > 0))
>
> Why not the simpler:
>
> #define __glibcpp_signed(T)     ((T)(-1) <= 0)
>
> that way we have an overlap on the range of the two types, so we won't
> get a warning.  We know for a fact that -1 != 0 for all known machine
> types (all machines are two's complement, or are required to behave as
> if they are two's complement, per the standard).
>

You keep saying this... where is this "must behave as two's compliment 
stated?"


> (unsigned int) -1 == 0xffffffff	  (assuming 32-bit int).

or with a valid one's compliment C99 compliant system
(unsigned int) -1 = 0xfffffffe;

>
> even on a one's complement's machine, without the standard conversion,
> the 'type punning' conversion of -1 would yield 0xfffffffe, which is
> still > 0.
>
Correct :).  I still don't think C enforces two's compliment.

Dave

> Warner
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to 
> "freebsd-current-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1046B4F9-B561-11D7-BE3B-0003937E39E0>