Showing with 55 additions and 0 deletions.
  1. +50 −0 test/runnable/imports/a15079.d
  2. +5 −0 test/runnable/test15079.d
50 changes: 50 additions & 0 deletions test/runnable/imports/a15079.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module imports.a15079;

Vector!string parseAlgorithmName()
{
assert(0);
}

struct Vector(ALLOC)
{
@disable this(this);

RefCounted!(Vector, ALLOC) dupr()
{
assert(0);
}
}

struct RefCounted(T, ALLOC)
{
~this()
{
T* objc;
.destroy(*objc);
}
}

// ----

void _destructRecurse(S)(ref S s)
if (is(S == struct))
{
static if (__traits(hasMember, S, "__xdtor") &&
__traits(isSame, S, __traits(parent, s.__xdtor)))
{
s.__xdtor();
}
}

void destroy(T)(ref T obj) if (is(T == struct))
{
_destructRecurse(obj);
() @trusted {
auto buf = (cast(ubyte*) &obj)[0 .. T.sizeof];
auto init = cast(ubyte[])typeid(T).init();
if (init.ptr is null) // null ptr means initialize to 0s
buf[] = 0;
else
buf[] = init[];
} ();
}
5 changes: 5 additions & 0 deletions test/runnable/test15079.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module test15079;

import imports.a15079;

void main() {}