[Issue 16011] [REG2.068] recursive RefCounted used to work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 8 05:03:23 UTC 2017


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
Compiling this now gives the following error:

core.exception.AssertError at dstruct.d(380): Assertion failure
----------------
0x005FD23F in _d_assertp
0x00408EFA in AttribDeclaration at C:\cbx\mars\attrib.d(181)
0x0045F5D7 in StructDeclaration at C:\cbx\mars\dstruct.d(373)
0x0045F5D7 in StructDeclaration at C:\cbx\mars\dstruct.d(373)
0x00474D79 in TemplateInstance at C:\cbx\mars\dtemplate.d(8272)
0x00474DDC in TemplateInstance at C:\cbx\mars\dtemplate.d(8290)
0x00470E61 in TemplateInstance at C:\cbx\mars\dtemplate.d(6361)
0x004714BB in TemplateInstance at C:\cbx\mars\dtemplate.d(6595)
0x004ECA1E in TypeInstance at C:\cbx\mars\mtype.d(8004)
0x004ECAE2 in TypeInstance at C:\cbx\mars\mtype.d(8027)
0x00434BE8 in VarDeclaration at C:\cbx\mars\declaration.d(1180)
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

It appears to be a forward reference error. The code itself cannot work because
RefCounted stores an instance of S in itself, and a struct cannot have itself
as a field. In fact, the same error occurs with the following example:

  struct RefCounted {
    S s;
  }

  struct S {
    int x;
    RefCounted s;
  }

--


More information about the Digitalmars-d-bugs mailing list