On Dec 20, 2003, at 1:54 AM, Leopold Toetsch wrote:

Jeff Clites <[EMAIL PROTECTED]> wrote:

The issue turns out to be that SIGFPE isn't raised on Mac OS X on
divide by zero. If I hack src/core_ops.c to explicitly raise(SIGFPE) in
the case of zero divisor then the tests pass, so the exception handling
code seems to be working correctly.

Ah, good take. As Perl5 obviously catches div by 0, we probably need some Configure test, if a platform signals int div/0.

I was told that int divide by zero has undefined behavior in C (though it's well-defined for floating-point operations, via IEEE 754), so it might be safest to always do an actual check in parrot (though that's an extra conditional branch around every int divide). What I'm thinking is that for a particular platform the behavior may not be consistent, so an accurate Configure check might be difficult. (Also, having this always directly raise a parrot exception should leave us with less platform-dependent code--e.g. I assume the Windows case wouldn't use signals.)


I'm not sure of the best way to fix the tests

Could your try float division?

That doesn't cause SIGFPE either. And actually this:


    set N10, 2.1
    div N10, 0
    print N10
    end

prints "inf".

Some more data: The behavior in these 2 cases matches the behavior of analogous C code on Mac OS X, as you'd expect. Also, on Intel--don't remember if this was Windows or Linux--float divide by zero in a C test case also gave "inf" via printf. I believe that the IEEE default behavior is to not raise a signal for invalid operations.

JEff



Reply via email to