www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15721] New: std.experimental.allocator dispose on interface

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

          Issue ID: 15721
           Summary: std.experimental.allocator dispose on interface
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: installer
          Assignee: nobody puremagic.com
          Reporter: joeyemmons yahoo.com

Seems calling dispose on an interface does not work. The following will cause
free to fail:

// someOutputRange is a ubyte[] output range of type O
auto malloc = Mallocator.instance;
OutputRange!(ubyte[]) range;
range =  malloc.make!(OutputRangeObject!(O, ubyte[]))(someOutputRange);

// do some stuff...

malloc.dispose(range); 


It fails because typeid on interfaces is wonky, who thought that was a good
idea...

It can be fixed by changing to: 
malloc.dispose(cast(Object)range); 
But honestly it should not be necessary and will 100% trip people up.

--
Feb 25 2016