[exim-dev] [Bug 1112] ${eval:INT_MIN/-1} gives SIGFPE

Top Page
Delete this message
Reply to this message
Author: Phil Pennock
Date:  
To: exim-dev
Subject: [exim-dev] [Bug 1112] ${eval:INT_MIN/-1} gives SIGFPE
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1112

Phil Pennock <pdp@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |





--- Comment #3 from Phil Pennock <pdp@???>  2011-05-09 11:00:20 ---
∀x, x%1 = 0
    x%-1 = 0


So I've introduced a bug whereby INT_MIN%-1 ≠ 0

Per email discussion with Florian Weimer, one fix might be:

  For x op y where x is INT_MIN and y is -1:
    if op is '*', leave alone
    if op is '/', change it to '*'
    if op is '%', coerce result to 0


This relies upon INT_MIN * -1 not raising an interrupt (on x86, which is where
all these issues are, AFAIK).

This means that INT_MIN / -1 remains a negative number, which is unintuitive
but consistent, since INT_MAX+1, although officially undefined, in practice
wraps around in twos-complement to become INT_MIN. I doubt that Exim is
running on non-twos-complement systems.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email