[Issue 11320] std.math.fmod, round, trunc are not yet pure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 26 11:48:04 UTC 2018


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

--- Comment #4 from Simon Naarmann <eiderdaus at gmail.com> ---
D language spec, Pure Functions:

https://dlang.org/spec/function.html#pure-functions

In Point 8, it says: As a concession to practicality, a pure function can also:
* read and write the floating point exception flags
* read and write the floating point mode flags, as long as those flags are
restored to their initial state upon function entry

That's exactly what happens in round(), but through indirection. The compiler
will not know that setControlState will be called a second time, and the
compiler will not know that setControlState enjoys the special concession of
the spec (it looks like any other impure function to the compiler).

--


More information about the Digitalmars-d-bugs mailing list