Re: Help with integer division overflow issue

Izumi Tsutsui <[email protected]> Wed, 10 Jan 2024 00:14:11 +0900
Newsgroups gmane.os.netbsd.ports.m68k
Message-ID <[email protected]>
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  [email protected]:/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