Port-m68k archive

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

Help with integer division overflow issue



Hey folks…

The NetBSD ATF tests discovered a bug in Qemu that causes Qemu to crash with a SIGFPE on x86-64 if the following test program is compiled and run in an m68k guest:

#include <limits.h>
#include <stdlib.h>

int divisor = -1;

int
main(int argc, char *argv[])
{

     if (argc > 1)
          divisor = atoi(argv[1]);

     return INT_MIN / divisor;
}

(Shenanigans are there to keep the compiler from const-folding.)

Basically, “INT_MIN / -1”.  It causes an integer overflow, and I forget exactly what the behavior of a real m68k is … does it raise an exception, or does it merely set the V flag?

Can someone with a Real 68040 (or 68030 or 68020) give it a whirl, please?

-- thorpej



Home | Main Index | Thread Index | Old Index