X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..5937940fc6c45b93eb95554996d1cd1b5a1bf307:/math/mpint.h diff --git a/math/mpint.h b/math/mpint.h index 7867f6a..e351b05 100644 --- a/math/mpint.h +++ b/math/mpint.h @@ -36,12 +36,21 @@ #include +#include + #ifndef CATACOMB_MP_H # include "mp.h" #endif /*----- Generic translation macros ----------------------------------------*/ +/* --- Warning damage control --- * + * + * GCC (at least) isn't clever enough to work out that the division in + * @MP_FROMINT@ is actually safe (since it will only be executed if @_i > + * MPW_MAX@, which would prove that @(type)MPW_MAX + 1 != 0@). + */ + /* --- @MP_FROMINT@ --- * * * Arguments: @d@ = destination multiprecision integer @@ -71,7 +80,9 @@ if (_i <= MPW_MAX) \ break; \ else \ - _i /= (type)MPW_MAX + 1; \ + MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), { \ + _i /= (type)MPW_MAX + 1; \ + }); \ } \ } else { \ _d->f |= MP_NEG; \ @@ -84,7 +95,9 @@ if (_i >= -MPW_MAX) \ break; \ else \ - _i /= (type)MPW_MAX + 1; \ + MUFFLE_WARNINGS_STMT(GCC_WARNING("-Wdiv-by-zero"), { \ + _i /= (type)MPW_MAX + 1; \ + }); \ } \ } \ \