clang gets numerical underflow wrong, please fix.
Steve Kargl
sgk at troutmask.apl.washington.edu
Sun Mar 13 18:46:13 UTC 2016
Consider this small piece of code:
#include <fenv.h>
#include <stdio.h>
float
foo()
{
static const volatile float tiny = 1.e-30f;
return (tiny * tiny);
}
int
main(void)
{
float x;
feclearexcept(FE_ALL_EXCEPT);
x = foo();
if (fetestexcept(FE_UNDERFLOW)) printf("FE_UNDERFLOW: ");
printf("x = %e\n", x);
return 0;
}
clang seems to get the underflow condition wrong.
% cc -o z a.c -lm && ./z
FE_UNDERFLOW: x = 0.000000e+00
% cc -O -o z a.c -lm && ./z
x = 1.000000e-60 <--- This is not a possible value!
% gcc -o z a.c -lm && ./z
FE_UNDERFLOW: x = 0.000000e+00
% gcc -O -o z a.c -lm && ./z
FE_UNDERFLOW: x = 0.000000e+00
% uname -a
FreeBSD laptop-kargl 11.0-CURRENT FreeBSD 11.0-CURRENT #1 r296724:
Sun Mar 13 09:12:38 PDT 2016
% cc --version
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564)
(based on LLVM 3.8.0)
% gcc --version
gcc (FreeBSD Ports Collection) 4.8.5
--
Steve
More information about the freebsd-toolchain
mailing list