Bug 17628 – formattedWrite is impure on double

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-09T20:47:42Z
Last change time
2019-12-07T14:03:18Z
Assigned to
No Owner
Creator
Bolpat

Comments

Comment #0 by qs.il.paperinik — 2017-07-09T20:47:42Z
pure void main() { import std.format : formattedWrite; auto app = appender!string; app.formattedWrite!"%s"(1.0); } fails. formattedWrite can purely do its job for int and string. It should also do for floating point types.
Comment #1 by dlang-bugzilla — 2017-07-10T21:34:34Z
Missing: import std.array : appender; Seems to be impure because it calls snprintf (which I think may change FPU flags or something).
Comment #2 by greensunny12 — 2017-07-10T22:52:07Z
> which I think may change FPU flags or something A hack would to create a pureSnprintf which resets errno to the value before its execution. There are talks about doing this for free: https://github.com/dlang/druntime/pull/1836
Comment #3 by edi33416 — 2018-04-19T15:09:00Z
Since `pureMalloc`, `pureCalloc` and `pureFree` got accepted[0], maybe we could do the same for `sprintf` and `snprintf`? [0] - https://github.com/dlang/druntime/pull/1836
Comment #4 by bugzilla — 2019-10-22T10:49:02Z
*** Issue 15321 has been marked as a duplicate of this issue. ***
Comment #5 by bugzilla — 2019-12-07T14:03:18Z
*** This issue has been marked as a duplicate of issue 7438 ***