Is the following a bug?

import std.c.string, core.memory;

void* makeNew(T)()
{
    T t = T.init;
    void* ptr = GC.malloc(T.sizeof);
    memcpy(ptr, &t, T.sizeof);
    return ptr;
}

void main()
{
    alias string T;
    T* iptr = cast(T*)makeNew!(T);
    (*iptr) = [1,2,3]; // this is allowed
}

Reply via email to