[Cython] C int division by zero
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Wed Apr 15 08:44:19 CEST 2009
Robert Bradshaw wrote:
> On Apr 14, 2009, at 1:04 PM, Carl Witty wrote:
>> On x86 processors, dividing -2**31 by -1 gives a processor signal;
>> under Linux, this results in exiting the process with "Floating point
>> exception". (Even though it's not floating point.) (Presumably, the
>> same thing happens when dividing -2**63 by -1 on a 64-bit processor; I
>> haven't tested.)
>
> Interesting corner case. This seems more like an overflow issue, and
> we're currently not trying to protect the user from those.
Well, yes, but usually with overflows one just gets the overflowed value
silently. With division overflow one crashes the application, which is
IMO much worse even if it is a very rare corner case.
I think we should raise OverflowError here under the same circumstances
as ZeroDivisionError.
--
Dag Sverre
More information about the Cython-dev
mailing list