From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Preventing warnings in FIXNUM_OVERFLOW_P Date: Thu, 18 Jan 2007 19:34:24 +0100 Message-ID: <85lkk0npzj.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1169145294 17440 80.91.229.12 (18 Jan 2007 18:34:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 18 Jan 2007 18:34:54 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 18 19:34:51 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1H7c64-0001VZ-3U for ged-emacs-devel@m.gmane.org; Thu, 18 Jan 2007 19:34:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H7c64-00038M-Oi for ged-emacs-devel@m.gmane.org; Thu, 18 Jan 2007 13:34:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H7c5q-000372-16 for emacs-devel@gnu.org; Thu, 18 Jan 2007 13:34:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H7c5o-000368-A0 for emacs-devel@gnu.org; Thu, 18 Jan 2007 13:34:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H7c5o-000362-4e for emacs-devel@gnu.org; Thu, 18 Jan 2007 13:34:32 -0500 Original-Received: from [151.189.21.43] (helo=mail-in-03.arcor-online.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H7c5k-00043c-3P; Thu, 18 Jan 2007 13:34:28 -0500 Original-Received: from mail-in-04-z2.arcor-online.net (mail-in-04-z2.arcor-online.net [151.189.8.16]) by mail-in-03.arcor-online.net (Postfix) with ESMTP id DFA4D275365; Thu, 18 Jan 2007 19:34:26 +0100 (CET) Original-Received: from mail-in-02.arcor-online.net (mail-in-02.arcor-online.net [151.189.21.42]) by mail-in-04-z2.arcor-online.net (Postfix) with ESMTP id D0697ABF5C; Thu, 18 Jan 2007 19:34:26 +0100 (CET) Original-Received: from lola.goethe.zz (dslb-084-061-053-209.pools.arcor-ip.net [84.61.53.209]) by mail-in-02.arcor-online.net (Postfix) with ESMTP id A3BD42D7C29; Thu, 18 Jan 2007 19:34:26 +0100 (CET) Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 75FCD1C4F90D; Thu, 18 Jan 2007 19:34:25 +0100 (CET) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Thu\, 18 Jan 2007 12\:27\:57 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:65281 Archived-At: Richard Stallman writes: > Ian Lance Taylor wrote: > > You can avoid it by using unsigned types. I think that something like > this will do the trick: > > #define FIXNUM_OVERFLOW_P(i) \ > ((unsigned long long)(i) > MOST_POSITIVE_FIXNUM \ > && (unsigned long long)(i) < MOST_NEGATIVE_FIXNUM) > > Would someone please give that approach a try and see if it works? I > am having too much trouble with concentration right now to see whether > that code is correct -- it might need somewhat more change than that > in order to get the comparisons right in an unsigned type. unsigned long long is neither guaranteed to exist on all supported architectures, nor guaranteed to be longer than long. It seems to me like something along the lines of #define FIXNUM_OVERFLOW_P(i) \ (((unsigned long)(i)-(unsigned long)MOST_NEGATIVE_FIXNUM) > \ (unsigned long)MOST_POSITIVE_FIXNUM) should do the trick. A few more casts than strictly necessary, but in that manner there is a chance that the compiler will not complain. I am assuming here that the natural type of i is (long int), if it isn't adapt the casts accordingly. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum