Re: GCC 3.3.1, new warnings with <limits>

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Sun, 13 Jul 2003 12:23:52 -0600 (MDT)
: >     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).

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

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.

Warner
Received on Sun Jul 13 2003 - 09:24:43 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:15 UTC