tech-userlevel archive

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

Re: standards on SIGFPE for divide by zero

On 3/1/11 1:41 PM, Matt Thomas wrote:
> On Mar 1, 2011, at 11:00 AM, Taylor R Campbell wrote:
>> Correctly signalling SIGFPE for integer division by zero is important.
>> Integer division by zero is a bug.  Robust, safe programming language
>> environments such as Emacs and Java need to report such bugs without
>> crashing: there is nothing that it is OK for (/ x 0) to return in
>> elisp, and it's also not OK for Emacs to crash -- you should get a
>> debugger if you want, and continue with your editing unharmed, unless
>> the division happens deep inside some critical path of Emacs.  It may
>> be OK in elisp to check every integer division for a divisor of zero,
>> but that's not OK in fast systems, which rely on handling SIGFPE to
>> report the error.
> PowerPC cann't raise an exception on integer divide by zero.  It can
> detect it if using the divwo instruction but it still won't raise an
> exception.  Instead you need to check the OV bit in the XER register.

This fact, combined with a limited survey of other OSes running on
powerpc, leads me to believe that the right thing to do here is to skip
the tests in question on powerpc platforms.

Thanks for all the feedback.


Home | Main Index | Thread Index | Old Index