Bug 9998 – RefCounted is impure

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-27T10:05:27Z
Last change time
2018-10-16T19:49:23Z
Keywords
pull
Assigned to
No Owner
Creator
Henning Pohl

Comments

Comment #0 by henning — 2013-04-27T10:05:27Z
Using RefCounted in a pure function is impossible: import std.typecons; void main() pure { RefCounted!int i; } ----- main.d(4): Error: pure function 'D main' cannot call impure function 'std.typecons.RefCounted!(int).RefCounted.~this' ----- Nothing in RefCounted is marked as pure in general.
Comment #1 by monarchdodra — 2013-04-29T03:44:52Z
There is indeed a few mistakes in RefCounted which I can take care of. I did hit this issue though: "Error: pure function 'std.typecons.RefCounted!(int).RefCounted.~this' cannot call impure function 'core.stdc.stdlib.free'" I can agree that "free" is not pure, as calling it twice on the same pointer will not yield the same result. However, there is no such thing as "trusted purity", so I'm not sure how to do that... I'll ask on the boards.
Comment #2 by andrej.mitrovich — 2014-04-24T11:32:16Z
Comment #3 by n8sh.secondary — 2018-10-16T19:49:23Z