xi.wang at gmail
Jul 14, 2012, 1:46 PM
Post #1 of 1
division by zero optimized away
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?
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg