https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88074
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> --- A GCC-side fix is to limit the exponent range mpfr uses (for TFmode this is -16381 to 16384). Not sure if mpfr or mpc need larger exponent ranges for intermediate computations... Lazily initialized in mpfr_from_real but I guess we could do it globally after target init? (IIRC Fedora loads mpfr and friends lazily?) diff --git a/gcc/realmpfr.c b/gcc/realmpfr.c index 10f05caaba3..1f421990f52 100644 --- a/gcc/realmpfr.c +++ b/gcc/realmpfr.c @@ -23,6 +23,7 @@ #include "tree.h" #include "realmpfr.h" #include "stor-layout.h" +#include "diagnostic-core.h" /* Convert from REAL_VALUE_TYPE to MPFR. The caller is responsible for initializing and clearing the MPFR parameter. */ @@ -30,6 +31,31 @@ void mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mp_rnd_t rndmode) { + static bool exp_initialized; + + if (!exp_initialized) + { + machine_mode mode; + int min_exp = 1; + int max_exp = 1; + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) + if (SCALAR_FLOAT_MODE_P (mode)) + { + const real_format *fmt = REAL_MODE_FORMAT (mode); + if (fmt) + { + if (fmt->emin < min_exp) + min_exp = fmt->emin; + if (fmt->emax > max_exp) + max_exp = fmt->emax; + } + } + if (mpfr_set_emin (min_exp) + || mpfr_set_emax (max_exp)) + sorry ("mpfr not configured to handle all float modes"); + exp_initialized = true; + } + /* We use a string as an intermediate type. */ char buf[128]; int ret;