www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9998] New: RefCounted is impure

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9998

           Summary: RefCounted is impure
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: henning still-hidden.de



PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 27 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9998


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 29 2013