From owner-freebsd-current@FreeBSD.ORG Sat Jul 12 20:12:16 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 57C5637B401 for ; Sat, 12 Jul 2003 20:12:16 -0700 (PDT) Received: from h00609772adf0.ne.client2.attbi.com (h00609772adf0.ne.client2.attbi.com [66.31.45.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2706043FBD for ; Sat, 12 Jul 2003 20:12:15 -0700 (PDT) (envelope-from rodrigc@crodrigues.org) Received: from h00609772adf0.ne.client2.attbi.com (localhost.ne.attbi.com [127.0.0.1])h6D3DNrx089126; Sat, 12 Jul 2003 23:13:23 -0400 (EDT) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: (from rodrigc@localhost)h6D3DM5D089125; Sat, 12 Jul 2003 23:13:22 -0400 (EDT) Date: Sat, 12 Jul 2003 23:13:12 -0400 From: Craig Rodrigues To: David Leimbach Message-ID: <20030713031312.GA89014@crodrigues.org> References: <20030712155333.GA79322@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i 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 03:12:16 -0000 On Sat, Jul 12, 2003 at 09:50:21PM -0500, David Leimbach wrote: > Heh that's because the offending macro __glibcpp_digits calls > __glibcpp_signed (T) > on an unsigned type which does a < compareison. > > std::numeric_limits ::digits on a 32bit FBSD will yield 31 > because its > got 31 bits for magnitude. > > Unfortunately the way it seems to go about calculating that stuff at > compile time > seems to be invalid due to the fact that it does < 0 compares on > unsigned types. > > Is this a gcc issue or a FBSD issue? [is this the original gcc c++ > header file or has > it been tweaked?] Hi, I think that this is a FreeBSD issue. I compiled the same file under Linux, with a GCC 3.3.1 checked out on 7/11 and did not encounter this warning. I looked in the source code of gcc and found this: /usr/src/contrib/gcc/c-common.c 2597 case LT_EXPR: 2598 if (extra_warnings && !in_system_header 2599 && ! (TREE_CODE (primop0) == INTEGER_CST 2600 && ! TREE_OVERFLOW (convert (c_common_signed_typ e (type), 2601 primop0)))) 2602 warning ("comparison of unsigned expression < 0 is alway s false"); 2603 value = boolean_false_node; 2604 break; I am guessing that the C preprocessor does not think that it is in a system header, and thus prints out the warning. If I take the following preprocessed source (test.ii) and compile it under FreeBSD with g++ -W -c test.ii: =============================================================================== # 1 "test.cc" # 1 "" # 1 "" # 1 "test.cc" # 1 "/usr/include/c++/3.3/iostream" 1 3 # 43 "/usr/include/c++/3.3/iostream" 3 static const int digits = (sizeof(unsigned int) * 8 - ((unsigned int)(-1) < 0)); =============================================================================== I get: In file included from test.cc:1: /usr/include/c++/3.3/iostream:44: warning: comparison of unsigned expression < 0 is always false If I compile the same file on my Linux box, with a gcc checked out from the FSF CVS repository (gcc version 3.3.1 20030711 (prerelease)), I do not get the warning. I am not an expert on the GNU C preprocessor format, but I changed two of the lines in the above file to: # 1 "/usr/include/c++/3.3/iostream" 1 # 43 "/usr/include/c++/3.3/iostream" and when I recompiled it under Linux, I also got the warning: In file included from test.cc:1: /usr/include/c++/3.3/iostream:44: warning: comparison of unsigned expression < 0 is always false Any GCC/FreeBSD expert care to comment? ;) -- Craig Rodrigues http://crodrigues.org rodrigc@crodrigues.org