Port-m68k archive

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

Re: Help with integer division overflow issue



thorpej@ wrote:

> #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;
> }
 :
> Can someone with a Real 68040 (or 68030 or 68020) give it a whirl, please?

Here it is:
---
milan-% uname -a
NetBSD milan 10.0_RC2 NetBSD 10.0_RC2 (MILAN-PCIIDE) #0: Mon Jan  1 14:04:52 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/atari/compile/MILAN-PCIIDE atari
milan-% sysctl hw.model
hw.model = Atari Milan (MC68040 CPU/MMU/FPU)
milan-% cat > test.c
#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;
}
milan-% cc -o test test.c
milan-% ./test
milan-% 
---

I.e. at least looks no exception.

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index