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.
An attempt at a fix: https://github.com/dlang/phobos/pull/5240
std.math.ieeeFlags is affected as well. ---- void main() { import std.math; float x = 1; x /= 0; assert(ieeeFlags.divByZero); /* fails; should pass */ } ----
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/09679c241f9ab4554e5bdabee998fd319e2eb4ac fix issue 17243 - std.math.{FloatingPointControl,ieeeFlags} don't work on x86_64 https://github.com/dlang/phobos/commit/83e199977607752df16167c557e2c0f5acb12be5 Merge pull request #5240 from aG0aep6G/FloatingPointControl fix issue 17243 - std.math.{FloatingPointControl,ieeeFlags} don't work on x86_64
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/09679c241f9ab4554e5bdabee998fd319e2eb4ac fix issue 17243 - std.math.{FloatingPointControl,ieeeFlags} don't work on x86_64 https://github.com/dlang/phobos/commit/83e199977607752df16167c557e2c0f5acb12be5 Merge pull request #5240 from aG0aep6G/FloatingPointControl
Commits pushed to newCTFE at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/09679c241f9ab4554e5bdabee998fd319e2eb4ac fix issue 17243 - std.math.{FloatingPointControl,ieeeFlags} don't work on x86_64 https://github.com/dlang/phobos/commit/83e199977607752df16167c557e2c0f5acb12be5 Merge pull request #5240 from aG0aep6G/FloatingPointControl
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/09679c241f9ab4554e5bdabee998fd319e2eb4ac fix issue 17243 - std.math.{FloatingPointControl,ieeeFlags} don't work on x86_64 https://github.com/dlang/phobos/commit/83e199977607752df16167c557e2c0f5acb12be5 Merge pull request #5240 from aG0aep6G/FloatingPointControl