www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C floating point functions don't set overflow/underflow flags?

I'm currently porting the last missing inline asm in std.math to gdc
syntax. There's one unittest which I just couldn't get working: It
checks for underflow/overflow flags after calling the exp function.

In gdc we currently forward std.math.exp to core.stdc.math.expl and it
turns out that the stdc functions don't set the status register (in
general, this also happens on dmd).

But why does that happen? AFAIK floating point exceptions have to be
enabled explicitly, but the status register should always get updated?

Source code:
-------------------------------
import core.stdc.math;
//import std.math;

void main()
{
    real arg = 10_000_000.0L;
    real a = expl(arg); //compare to std.math.exp on dmd
    assert(a == real.infinity);
}
-------------------------------

Set a breakpoint with gdb on line 8 and type "info float". I also tried
a more complicated example to make sure there is no constfolding or
inlining and the expl function does get called normally, but the flags
are never set.
Jun 01 2013