Nothrow, pure in druntime
Walter Bright
newshound1 at digitalmars.com
Mon Jan 26 01:29:38 PST 2009
Don wrote:
> tango.math doesn't use the C library at all, except when inline asm is
> unavailable. Of they differ from the C functions, in that none of them
> set errno!
> One really annoying issue still remains, though -- the floating point
> flags in the CPU. They are entirely deterministic, but are they
> considered to be part of the return value of the function? Or would we
> allow them to be ignored?
> A compiler could check the exception flags before allowing memoisation.
> But one could also do the same thing for 'errno'.
>
> Likewise, floating point rounding modes. Essentially, the floating point
> status register is a hidden global variable, read from# and written to
> during every floating point operation.
>
> # - only the rounding mode and truncation affect the return value. We
> could deal with it by regarding that as a whole-program setting. But
> (depending on the CPU), the old exception flags generally get ORed with
> the new exception flags.
Those are good points. I don't know what the answer is. My inclination
is to say if your program relies on changing the rounding mode or
fiddles with the exception flags, it's undefined behavior.
> Also, you can set the flags to allow any floating point function to
> throw a hardware exception. It's difficult for any function using
> floating point to claim to be nothrow under ANY circumstances; but
> that's a horrible limitation.
I would say that is not supported by D. I've never heard of a use for them.
More information about the Digitalmars-d
mailing list