Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: prevent SIGFPE on systems where LONG_MIN < -LONG_MAX



2012/9/3 Mikael Magnusson <mikachu@xxxxxxxxx>:
> See also this thread,
> http://www.zsh.org/mla/workers/2011/msg00613.html

Thanks.

I think we want a warning, as we have for division by zero. The shell
should not crash, neither should it return incorrect results.

The patch should work whatever the underlying type behind zlong is.

2012/9/3 Peter Stephenson <Peter.Stephenson@xxxxxxx>:
> So what's the answer, then?  Jérémie's patch makes only limited
> assumptions; I think the #if is there simply to see if we can assume
> two's complement arithmetic (it seems the preprocessor isn't keen on
> "#if LONG_MIN - 1 == LONG_MAX", I suppose it's not required to use
> "long" precision) in which case the test should work.  It might not
> cover all real cases, but that's a lesser evil.

Testing LONG_MIN < -LONG_MAX tells if the opposite of the minimal long
value is a representable value. It makes the assumption that the
answer is valid for ZSH_64_BIT_TYPE too.
On systems where LONG_MIN == -LONG_MAX, the shell should not raise a warning.

Best regards,

-- 
Jérémie



Messages sorted by: Reverse Date, Date, Thread, Author