[Issue 18828] [-betterC] helpless error in object.d

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 8 11:47:14 UTC 2018


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

--- Comment #7 from Mike Franklin <slavo5150 at yahoo.com> ---
The problem is this code in object.d:

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).initializer();
        if (init.ptr is null) // null ptr means initialize to 0s
            buf[] = 0;
        else
            buf[] = init[];
    } ();
}

The call to `typeid` needs to return a `TypeInfo` instance.  Is there a way to
get the initializer at compile-time without a runtime call to `typeid`?

--


More information about the Digitalmars-d-bugs mailing list