https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105101

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
There is another, much worse, problem, reported and analyzed by "Michael S"
on comp.arch. The code has

#ifdef HAVE_SQRTL
  {
    long double xl = (long double) x;
    if (xl <= LDBL_MAX && xl >= LDBL_MIN)
      {
        /* Use long double result as starting point.  */
        y = (__float128) sqrtl (xl);

        /* One Newton iteration.  */
        y -= 0.5q * (y - x / y);
        return y;
      }
  }
#endif

which assumes that long double has a higher precision than
normal double.  On x86_64, this depends o the settings of the
FPU flags, so a number like 0x1.06bc82f7b9d71dfcbddf2358a0eap-1024 
is corrected with 32 ULP of error because there is only a single
round of Newton iterations if the FPU flags are set to normal precision.

I believe we can at least fix that before the gcc 12 release, by
simply removing the code I quoted.

Reply via email to