Skip to content

Commit

Permalink
fixed issue 15721
Browse files Browse the repository at this point in the history
  • Loading branch information
Basile Burg committed Mar 1, 2016
1 parent 098ce23 commit 211c10a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion std/experimental/allocator/package.d
Expand Up @@ -1099,7 +1099,19 @@ void dispose(A, T)(auto ref A alloc, T p)
if (is(T == class) || is(T == interface))
{
if (!p) return;
auto support = (cast(void*) p)[0 .. typeid(p).initializer.length];
static if (is(T==interface))

This comment has been minimized.

Copy link
@andralex

andralex Mar 3, 2016

Member

there should be spaces around ==, even the rest of the code in this PR observes that

{
version(Windows)
{
import core.sys.windows.unknwn;
static assert(!is(T: IUnknown), "COM interfaces can't be destroyed in "
~ __PRETTY_FUNCTION__);
}
auto ob = cast(Object) p;
}
else
alias ob = p;
auto support = (cast(void*) ob)[0 .. typeid(ob).initializer.length];
destroy(p);
alloc.deallocate(support);
}
Expand Down Expand Up @@ -1155,6 +1167,20 @@ unittest
theAllocator.dispose(arr);
}

unittest //bugzilla 15721
{
import std.experimental.allocator.mallocator: Mallocator;

interface Foo {}
class Bar: Foo {}

Bar bar;
Foo foo;
bar = Mallocator.instance.make!Bar;
foo = cast(Foo) bar;
Mallocator.instance.dispose(foo);
}

/**
Returns a dynamically-typed $(D CAllocator) built around a given statically-
Expand Down

0 comments on commit 211c10a

Please sign in to comment.