Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294455

Potential bug in __ieee754_asin: misleading indentation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8, 11, 17, 19, 20
    • core-libs
    • None

      See e_asin.c:
      https://github.com/openjdk/jdk/blob/1abf971b93222f422c0026cee944a6db214f955a/src/java.base/share/native/libfdlibm/e_asin.c#L100-L105

                  if(ix<0x3e400000) { /* if |x| < 2**-27 */
                      if(huge+x>one) return x;/* return x with inexact if x!=0*/
                  } else
                      t = x*x;
                      p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
                      q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
                      w = p/q;
                      return x+x*w;

      Note that "else" branch only covers "t = x*x". So, if we pass `ix<0x3e400000` and fail `huge+x>one`, we fall through to `p = ...` and probably return `x`, since `t` is still `0`, then p is `0`, then w is `0`, then `x + x*w` is `x`.

      I am not sure if this leads to a calculation/precision bug or not. It is probably okay since we are dealing with very small `x` and `asin(0)` is `0`.

      We would have noticed it earlier if we did not ignore -Wmisleading-indentation: JDK-8294456.

            rgiulietti Raffaello Giulietti
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: