www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17884] New: fwd reference leads to dmd assert failure

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

          Issue ID: 17884
           Summary: fwd reference leads to dmd assert failure
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

struct S()
{
    void delegate() d;
}

S!() f_Ds(U)()
{
pragma(msg,U);
    static if (is(U == struct))
        return S!()
            (
                {
                    foreach (i, field; U.init.tupleof)
                        f_Ds!(typeof(field))();
                }
            );

    else
        return f_Ds!(D)();
}

void f_E()
{
    auto f = S!()
        (
            {
                enum x = is(typeof(f_Ds!(D*)()));
                f_Ds!(D*)();
            }
        );
}

struct A
{
    D d;
}

struct D
{
    A a;
    int b;
}

void main()
{
    f_E();
    f_Ds!(D*)();
}
-----------------------
dmd bug
bug.d(40): Error: struct bug.A no size because of forward reference

core.exception.AssertError dstruct.d(380): Assertion failure
----------------
0x005FD23F in _d_assertp
0x0040477A in AggregateDeclaration at C:\cbx\mars\aggregate.d(339)
0x00404890 in AggregateDeclaration at C:\cbx\mars\aggregate.d(377)
0x004EE4E0 in TypeStruct at C:\cbx\mars\mtype.d(8662)
0x00434C64 in VarDeclaration at C:\cbx\mars\declaration.d(1199)
0x0045F5D7 in StructDeclaration at C:\cbx\mars\dstruct.d(373)
0x00454D54 in Module at C:\cbx\mars\dmodule.d(1065)
0x004D9F9F in int ddmd.mars.tryMain(uint, const(char)**) at
C:\cbx\mars\mars.d(847)
0x004DAB43 in _Dmain at C:\cbx\mars\mars.d(1086)
0x005FF73B in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFNlZv
0x005FF6FF in scope void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()
0x005FF600 in _d_run_main
0x004DCDD8 in main at C:\cbx\mars\root\stringtable.d(7)
0x0061B245 in mainCRTStartup
0x74F3336A in BaseThreadInitThunk
0x77359902 in RtlInitializeExceptionChain
0x773598D5 in RtlInitializeExceptionChain

--
Oct 07