Division by -1 is also known to cause signed integer overflow. In this
case, on x86_64 CPUs, you don't even need a '-ftrapv' option. Test case:

(poke) var x = -4611686018427387904;
(poke) var y = 2*x;
(poke) y / -1
Gleitkomma-Ausnahme (Speicherabzug geschrieben)

In the debugger:

(poke) var x = -4611686018427387904;
(poke) var y = 2*x;
(poke) y / -1

Thread 1 "poke" received signal SIGFPE, Arithmetic exception.
0x00007ffff7b8ea84 in pvm_execute_or_initialize (jitter_initialize=63, 
jitter_initial_program_point=0xac5f90, 
    jitter_original_state=0x632310) at ../../libpoke/pvm.jitter:2325
2325        PVM_CHECKED_BINOP (LONG, LONG, LONG, /);

You should get away without a crash by using the INT_DIVIDE_OVERFLOW
macro from Gnulib's intprops.h.

Bruno


Reply via email to