openlibm
openlibm copied to clipboard
log1p(-1) does not raise exception
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
This hasn't yet been fixed