unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: Preventing warnings in FIXNUM_OVERFLOW_P
Date: Thu, 18 Jan 2007 14:39:05 -0500	[thread overview]
Message-ID: <jwvps9cktwf.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <85lkk0npzj.fsf@lola.goethe.zz> (David Kastrup's message of "Thu\, 18 Jan 2007 19\:34\:24 +0100")

>> 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)

That might be OK if we're trying to obfuscate the code.
Eli's current workaround is still the least bad I've seen.


        Stefan

  reply	other threads:[~2007-01-18 19:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18 17:27 Preventing warnings in FIXNUM_OVERFLOW_P Richard Stallman
2007-01-18 18:34 ` David Kastrup
2007-01-18 19:39   ` Stefan Monnier [this message]
2007-01-19 10:42     ` Richard Stallman
2007-01-19 11:50       ` Eli Zaretskii
2007-01-19 19:19         ` Stefan Monnier
2007-01-20  2:10           ` Richard Stallman
2007-01-20 13:45             ` Eli Zaretskii
2007-01-21  6:49               ` Richard Stallman
2007-01-19 10:42   ` Richard Stallman
2007-01-18 21:49 ` Eli Zaretskii
2007-01-19 10:43   ` Richard Stallman
2007-01-19 10:57     ` Eli Zaretskii
2007-01-20  2:10       ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvps9cktwf.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).