From owner-freebsd-current@FreeBSD.ORG Sun Jul 13 08:22:00 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 A3AA537B401 for ; Sun, 13 Jul 2003 08:22:00 -0700 (PDT) Received: from hexagon.stack.nl (hexagon.stack.nl [131.155.140.144]) by mx1.FreeBSD.org (Postfix) with ESMTP id B603C43F75 for ; Sun, 13 Jul 2003 08:21:59 -0700 (PDT) (envelope-from jilles@stack.nl) Received: by hexagon.stack.nl (Postfix, from userid 65534) id 652A91C65; Sun, 13 Jul 2003 17:21:58 +0200 (CEST) Received: from toad.stack.nl (zen.stack.nl [2001:610:1108:5010::130]) by hexagon.stack.nl (Postfix) with ESMTP id 7E0251C44; Sun, 13 Jul 2003 17:21:54 +0200 (CEST) Received: by toad.stack.nl (Postfix, from userid 1677) id 543E595; Sun, 13 Jul 2003 17:21:54 +0200 (CEST) Date: Sun, 13 Jul 2003 17:21:54 +0200 From: Jilles Tjoelker To: Craig Rodrigues Message-ID: <20030713152154.GA96653@stack.nl> References: <20030712155333.GA79322@crodrigues.org> <20030713031312.GA89014@crodrigues.org> <20030713000559.28c18be6.kabaev@mail.ru> <20030713044331.GA89785@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030713044331.GA89785@crodrigues.org> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-5.0 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) 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 15:22:01 -0000 On Sun, Jul 13, 2003 at 12:43:31AM -0400, Craig Rodrigues wrote: > The warnings seemed to be caused by this code in > /usr/include/c++/3.3/limits: > ========================================================================= > 630 static const int digits = __glibcpp_digits (unsigned int); > 631 static const int digits10 = __glibcpp_digits10 (unsigned int); > ========================================================================= > The macros are defined in the same file here: > ============================================================================ > 134 #define __glibcpp_signed(T) ((T)(-1) < 0) > > 142 #define __glibcpp_digits(T) \ > 143 (sizeof(T) * __CHAR_BIT__ - __glibcpp_signed (T)) > ============================================================================ > The expanded macros look like: > static const int digits = (sizeof(unsigned int) * 8 - ((unsigned int)(-1) < 0)); > static const int digits10 = ((sizeof(unsigned int) * 8 - ((unsigned int)(-1) < 0)) * 643 / 2136); Perhaps this would work: #define __glibcpp_signed(T) (!((T)(-1) > 0)) I have tried this with GCC 3.2 (5.1-BETA i386, -W -Wall), and a plain C program (not C++). cc and c++ do the same. The old macro gives the warning about comparing signed types, but the new one does not. They both work for int, u_int, unsigned int and char. The compiler moans about (T)(-1) >= 0 as well. Is the assumption that (unsigned type)(-1) is never zero valid? If it's not, try (!((T)(-1) > 0 || (T)(-1) == 0)). GCC does not seem to moan about that, even though it's exactly the same as using >=. Jilles Tjoelker