[Issue 15726] New: forward reference error for circular classes, RefCounted

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Feb 25 21:05:46 PST 2016


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

          Issue ID: 15726
           Summary: forward reference error for circular classes,
                    RefCounted
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: erik at cruiserhouse.com

The code below fails to compile with the following error:

/usr/local/Cellar/dmd/2.070.1-b1_1/include/dlang/dmd/object.d(2762): Error:
struct bug.Statement!int.Statement.Payload no size yet for forward reference

It's an issue involving circular struct references and RefCounted (with a
reduced version below). Possible related issues: 12000, 14390

The failing PR found via digger:

https://github.com/D-Programming-Language/dmd/pull/4457

Here is the failing code:

struct RefCounted(T) {
    struct Impl {
        T _payload;
    }

    Impl* _store;

    ~this() {
        destroy(_store._payload);
    }
}

struct Connection(T) {
    alias Statement = .Statement!T;
}

struct Statement(T) {
    alias Connection = .Connection!T;

    struct Payload {
        Connection con;
    }

    RefCounted!Payload Data;
}

Connection!int x;

--


More information about the Digitalmars-d-bugs mailing list