From owner-freebsd-current@FreeBSD.ORG Sun Jul 13 13:39:03 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0680837B401 for ; Sun, 13 Jul 2003 13:39:03 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 996B343F75 for ; Sun, 13 Jul 2003 13:39:01 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id GAA27277; Mon, 14 Jul 2003 06:38:25 +1000 Date: Mon, 14 Jul 2003 06:38:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Marcel Moolenaar In-Reply-To: <20030713183151.GA78045@dhcp01.pn.xcllnt.net> Message-ID: <20030714061544.I5570@gamplex.bde.org> References: <20030712155333.GA79322@crodrigues.org> <20030713000559.28c18be6.kabaev@mail.ru> <20030713183151.GA78045@dhcp01.pn.xcllnt.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Craig Rodrigues cc: Alexander Kabaev cc: freebsd-current@freebsd.org Subject: Re: GCC 3.3.1, new warnings with X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jul 2003 20:39:03 -0000 On Sun, 13 Jul 2003, Marcel Moolenaar wrote: > On Sun, Jul 13, 2003 at 08:23:54AM -0500, David Leimbach wrote: > > > > This is a good policy in general, however, one could easily argue that > > what > > is trying to be determined with signedness and such being > > less-than-compared > > to 0 isn't really a big deal and possibly the only way to implement this > > numeric_limits::digits thing without any type introspection which > > C++ currently > > lacks. > > What about? > > #define issigned(T) (((T)(0)>(T)(~0)) ? 1 : 0) This is worse than any version that uses -1 instead of ~0, since ~0 gives implementation-defined behaviour. I think it can set trap bits. Anyway, the value of ~0 is unclear. I think it is -0 == 0 on 1's complement machines. Since its value is unclear, the result of converting this value to even an unsigned type T is also unclear. I think the above actually does work for the 3 representations in C99 iff ~0 has no trap bits, but this is unclear. These problems are avoided by using plain -1. Bruce