Re: clang gets numerical underflow wrong, please fix.

2016-03-14 Thread Steve Kargl
On Mon, Mar 14, 2016 at 08:23:33PM +0100, Dimitry Andric wrote: > > Maybe this is a usable workaround for libm. > Thanks for looking into this. I just read the audit trail at llvm.org. Searching the clang user manual turns up The support for standard C in clang is feature-complete

Re: clang gets numerical underflow wrong, please fix.

2016-03-14 Thread Dimitry Andric
On 14 Mar 2016, at 02:53, Steve Kargl wrote: ... > #include > #include > > int > main(void) > { > int i; > float x = 1.f; > i = 0; > feclearexcept(FE_ALL_EXCEPT); > do { > x *= 2; > i++; > printf("%d %e\n", i, x); > }

Re: clang gets numerical underflow wrong, please fix.

2016-03-13 Thread Steve Kargl
On Mon, Mar 14, 2016 at 01:02:20AM +0100, Dimitry Andric wrote: > > $ gcc -O overflow-iter.c -o overflow-iter-gcc -lm > $ ./overflow-iter-gcc > FE_OVERFLOW: x = inf after 1024 iterations > $ gcc -O2 overflow-iter.c -o overflow-iter-gcc -lm > $ ./overflow-iter-gcc > FE_OVERFLOW: x = inf after

Re: clang gets numerical underflow wrong, please fix.

2016-03-13 Thread Steve Kargl
On Mon, Mar 14, 2016 at 01:02:20AM +0100, Dimitry Andric wrote: > On 13 Mar 2016, at 21:10, Steve Kargl > wrote: > > Thanks for the quick reply. But, it must be using an 80-bit > > extended double instead of a double for storage. This variation > > > >

Re: clang gets numerical underflow wrong, please fix.

2016-03-13 Thread Dimitry Andric
On 13 Mar 2016, at 21:10, Steve Kargl wrote: > On Sun, Mar 13, 2016 at 09:03:57PM +0100, Dimitry Andric wrote: ... >> So it's storing the intermediate result in a double, for some reason. >> The fnstsw will then result in zero, since there was no underflow at >>

Re: clang gets numerical underflow wrong, please fix.

2016-03-13 Thread Steve Kargl
On Sun, Mar 13, 2016 at 09:03:57PM +0100, Dimitry Andric wrote: > On 13 Mar 2016, at 19:25, Steve Kargl > wrote: > > > > Consider this small piece of code: > > > > #include > > #include > > > > float > > foo() > > { > > static const volatile float tiny

clang gets numerical underflow wrong, please fix.

2016-03-13 Thread Steve Kargl
Consider this small piece of code: #include #include 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: ");