www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17243] New: std.math.FloatingPointControl doesn't work on

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

          Issue ID: 17243
           Summary: std.math.FloatingPointControl doesn't work on x86_64
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Compile with dmd (e.g. 2.073.0) and run:

----
void main()
{
    import std.math;
    FloatingPointControl fpctrl;

    fpctrl.rounding = FloatingPointControl.roundUp;
    float u = 1;
    u += 0.1;

    fpctrl.rounding = FloatingPointControl.roundDown;
    float d = 1;
    d += 0.1;

    assert(u > d); /* fails; should pass */
}
----

Similar tests can be constructed for floating point exception flags and masks.

The problem is that dmd generates SSE additions, but FloatingPointConrol
doesn't affect SSE's control/status register MXCSR.

See also issue 5323.

--
Mar 04 2017