emacs-devel
[Top][All Lists]
Advanced

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

Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?


From: Eli Zaretskii
Subject: Re: macro FIXNUM_OVERFLOW_P in lisp.h is valid ?
Date: Sat, 24 Oct 2009 12:16:47 +0200

> From: Andreas Schwab <address@hidden>
> Cc: Stefan Monnier <address@hidden>,  address@hidden,  address@hidden
> Date: Sat, 24 Oct 2009 11:40:34 +0200
> 
> >>   (FIXNUM_OVERFLOW_P): Cast I to EMACS_INT in comparisons
> >>   in case I is of some unsigned type, in which case
> >>   MOST_NEGATIVE_FIXNUM will be converted to unsigned, and the
> >>   comparison becomes bogus.
> >
> > Right, sorry for my failing memory.
> >
> > So I think the change made yesterday by Andreas should be reverted.
> 
> The cast does not really fix the described problem anyway.  Converting
> an unsigned value to a signed type when the value is out of range for
> the signed type results in an implementation defined value.  That is
> less bad than undefined behaviour, but still not portable.

That's true, but I think we need to fix both problems.  In any case, I
think having a small unsigned value is more frequent than having a
very large unsigned value, which is probably the reason why the former
was discovered in 2001, while the latter only now.

Maybe the solution is to use a real function rather than a macro.




reply via email to

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