[Issue 13474] Discard excess precision when returning double in x87 register

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Feb 15 21:02:38 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13474

yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
            Summary|32 bit DMD optimizer FP     |Discard excess precision
                   |arithmetic bug              |when returning double in
                   |                            |x87 register
           Severity|blocker                     |enhancement

--- Comment #15 from yebblies <yebblies at gmail.com> ---
I've thought about it some more, and I don't think this is behaving incorrectly
given what D does specify about floating point behaviour.

1. Nothing in any ABI I can find specifies that return values must be
truncated.  (gcc does have a -ffloat-store flag)

2. D allows floating point intermediates to be at a higher precision than the
operand types.  This doesn't explicitly include return values, but...

3. D allows inlining, which means even if return values are explicitly excluded
from (2) then it still can't be relied upon.

So, I conclude that calculating and returning floating point values at a higher
precision than specified is allowed in D.

The code where you hit the problem can be fixed by:

1. Fixing the tests to not rely on maximum precision.
2. Using a wrapper on function calls where precision must be forced. (An
intrinsic to force precision loss has been discussed in the past)
3. Lobbying Walter for a language change enforcing this in some way.

I've changed the platform as this behaviour is possible on other platforms too
even if the current code generator never hits those cases.

--


More information about the Digitalmars-d-bugs mailing list