I'm pretty sure that this code should compile (https://dpaste.dzfl.pl/cf1e1ee6ef4b):

struct A(T) {
    ~this() {
        char[T.sizeof] data;
    }
}

struct B(T) {
    A!T foo;
}

struct C {
    B!C bar;
}

void main() {
    C c;
}

But it doesn't:
/d300/f416.d(3): Error: struct f416.C no size because of forward reference /d300/f416.d(12): Error: template instance f416.B!(C) error instantiating

Notice that the same C++ code compiles without problems:

template<typename T> struct A {
    ~A() {
        char data[sizeof(T)];
    }
};

template<typename T> struct B {
    A<T> foo;
};

struct C {
    B<C> bar;
};

int main() {
    C c;
}

A simple recursion is compiled successfully (https://dpaste.dzfl.pl/5a8ff73bfa88):

struct A(T) {
    ~this() {
        char[T.sizeof] data;
    }
}

struct C {
    A!C bar;
}

void main() {
    C c;
}

Reply via email to