emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preventing warnings in FIXNUM_OVERFLOW_P


From: Stefan Monnier
Subject: Re: Preventing warnings in FIXNUM_OVERFLOW_P
Date: Thu, 18 Jan 2007 14:39:05 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]