Error in optimizing exp(-Inf) using egcc or g++
Matthias Klose
doko@cs.tu-berlin.de
Sun May 16 09:30:00 GMT 1999
[This bug was reported to me as a co-maintainer of the Debian GNU/Linux EGCS
packages. Please Cc: 37154@bugs.debian.org in your response so it gets
archived in the Debian bugtracking system ( http://www.debian.org/Bugs/ ).
Please Cc me as I'm not on the egcs-bugs list.]
Linux i486 (Pentium II)
glibc-2.1 (CVS 1999-05-08).
egcs 2.93.21 (19990502)
kernel 2.2.9
With any level of optimization > 0, exp(-Inf) is NaN:
E.g. here is little code, tmp.c:
#include <stdlib.h>
#include <math.h>
#include <huge_val.h>
int main()
{
double inf = -HUGE_VAL;
printf(" -Inf=%e\n", inf);
printf("exp(-Inf)=%e\n", exp(inf));
return 0;
}
> egcc -O3 -o tmp tmp.c -lm
> ./tmp
-Inf=-Inf
exp(-Inf)=NaN
But,
> egcc -O0 -o tmp tmp.c -lm
> ./tmp
-Inf=-Inf
exp(-Inf)=0.000000e+00
More information about the Gcc-bugs
mailing list