[Issue 17230] Destroy forward reference error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 25 06:41:32 UTC 2017


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

Mike <slavo5150 at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150 at yahoo.com

--- Comment #1 from Mike <slavo5150 at yahoo.com> ---
This doesn't appear to have anything to do with `destroy`.  You can reproduce
the same error with the following code

struct A
{
     B b;
}

struct B
{
    Wrap!A val;
}

struct Wrap(T)
{
   ~this()
    {
        assert(T.sizeof == 0);
    }
}

onlineapp.d(15): Error: struct onlineapp.A no size because of forward reference

See https://run.dlang.io/is/TC4uxk

So, the error seems to be due to a bug in DMD's template instantiation.  If the
template is instantiated manually with something like this...

struct A
{
     B b;
}

struct B
{
    C val;
}

struct C
{
   ~this()
    {
        assert(A.sizeof == 0);
    }
}

void main() {}

... it works fine.  See https://run.dlang.io/is/iPAFN8

--


More information about the Digitalmars-d-bugs mailing list