I'm using the standard plan9 kernel running in a 32bit i386 VirtualBox VM.
The fcr (printed with %ulb) was 1001000000 which seems to be FPPEXP and FPPDBL.

Your code does indeed produce the expected output on my VM.

So if my kernel isn't really doing the right thin; and the 'expected' behavior would be for my program to enter an infinite loop. Considering that's not happening (and assuming I understand correctly), perhaps something in notes/noted() needs looked at?


On Fri, Apr 18, 2014 at 9:10 PM, erik quanstrom <quanstro@quanstro.net> wrote:
i imagine what happened is your kernel doesn't really do the right thing
on catching the exception.  i think the caught exception should restart
the program *exactly* where it left off, dividing by zero, which will lead
to an infinite loop.  if your kernel skipped the instruction, then the value
of (in my case r) would be whatever the previous value was.  if this is the
statement that initializes r, this could be random trash on the stack.  which
would lead to a mystery exception later on for some value of trash on stack.

- erik
----

this provides the correct result.

#include <u.h>
#include <libc.h>

void
main(void)
{
        double zero, r;

        setfcr(getfcr() & ~FPZDIV);

        zero = 0.;
        r = 1.;
        r = r/zero;
        print("%g\n", r);
        exits("");
}