[gcc libm][coshl, acoshl, cacoshf, cacosh wrong results]

Daniel Kochmański daniel@turtleware.eu
Thu Dec 5 18:23:00 GMT 2019


Hey,

while testing ECL on Cygwin I've encountered a few issues with how the
functions coshl and acoshl treat infinities (long double
functions). Results are invalid and that does not happen on Linux.

Please consider the following code:

-- cut --
#include <math.h>
#include <stdio.h>
#include <complex.h>

int main () {
  long double num1 = -INFINITY;
  double      num2 = -INFINITY;

  printf("negative infinities\n");
  printf("long double: %Lf, double: %f\n", num1, num2);

  num1 = coshl(num1);
  num2 = cosh (num2);

  printf("map cosh (should flip infinities to positive)\n");
  printf("long double: %Lf, double: %f\n", num1, num2);

  num1 = INFINITY;
  num2 = INFINITY;

  printf("positive infinities\n");
  printf("long double: %Lf, double: %f\n", num1, num2);

  num1 = acoshl(num1);
  num2 = acosh (num2);

  printf("map acosh (should remain positive infinities)\n");
  printf("long double: %Lf, double: %f\n", num1, num2);

  return 0;
}
-- cut --

coshl returns negative infinity (incorrectly) and acoshl returns a nan.

Moreover cacoshf and cacosh for infinities return nan, and a surprise,
long double variant works fine. I didn't test for other values than
infinities.

GCC 7.4.0
Cygwin installed from Setup version 2.897 (64 bit)
Platform: Windows 7 Professional (x86-64)

Best regards,
Daniel

--
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański      | www.turtleware.eu

"Be the change that you wish to see in the world." - Mahatma Gandhi

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list