openlibm icon indicating copy to clipboard operation
openlibm copied to clipboard

log1p(-1) does not raise exception

Open kargl opened this issue 5 years ago • 2 comments

kargl avatar Mar 13 '20 21:03 kargl

Here's the test code. Sorry about poor formatting, but github interface does not seem to hone fixed width fonts with whitespace.

#include <fenv.h>
#include <math.h>
#include <stdio.h>
int main(void) {
   fexcept_t flags;
   float x,y;
   x = -1.f;
   feclearexcept(FE_ALL_EXCEPT);
   y = log1p(x);
   fegetexceptflag(&flags, FE_ALL_EXCEPT);
  if (!(flags & FE_DIVBYZERO)) printf("Whoops! Where FE_DIVBYZERO?\n");
  printf("%e %e\n", x, y);
  return (0);
}

This was fixed in FreeBSD by

r251024 | das | 2013-05-27 01:50:10 -0700 (Mon, 27 May 2013) | 9 lines
cc -o z a.c openlibm-master/libopenlibm.a
% ./z
Whoops! Where FE_DIVBYZERO?
-1.000000e+00 -inf

kargl avatar Mar 13 '20 21:03 kargl

This hasn't yet been fixed

oscardssmith avatar May 31 '22 15:05 oscardssmith