division by zero optimized away
xi.wang at gmail.com
Sat Jul 14 22:46:21 CEST 2012
There are two occurrences of intentional division by zero in mpi.
Division by zero is undefined behavior in C, and it may not work
1) Division by zero doesn't "provoke a signal" on architectures
2) C compilers like clang will optimize away these divisions, even
though the code tries "to make the compiler not remove" them.
gcry_mpi_powm() at mpi/mpi-pow.c:78
msize = 1 / msize; /* Provoke a signal. */
_gcry_mpih_divrem() at mpi/mpih-div.c:213
/* We are asked to divide by zero, so go ahead and do it! (To make
the compiler not remove this statement, return the value.) */
return 1 / dsize;
How about using something like signal(SIGFPE) instead?
More information about the Gcrypt-devel