Thread overview
[Issue 16011] [REG2.068] recursive RefCounted used to work
May 10, 2016
ag0aep6g@gmail.com
May 13, 2016
Kenji Hara
Oct 08, 2017
Walter Bright
Oct 08, 2017
Walter Bright
Oct 08, 2017
Walter Bright
Oct 08, 2017
ag0aep6g@gmail.com
Dec 17, 2019
Walter Bright
May 10, 2016
https://issues.dlang.org/show_bug.cgi?id=16011

--- Comment #1 from ag0aep6g@gmail.com ---
(In reply to ag0aep6g from comment #0)
> Marking this as a phobos regression. I have a reduction, but that works up to 2.069, so there may be something else going on. Filing that separately.

Filed as issue 16012.

--
May 13, 2016
https://issues.dlang.org/show_bug.cgi?id=16011

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
          Component|phobos                      |dmd
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
I concluded this is a compiler issue.

https://github.com/dlang/dmd/pull/5773

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=16011

Walter Bright <bugzilla@digitalmars.com> changed:

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

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

core.exception.AssertError@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;
  }

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=16011

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/7196

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=16011

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
Looks like my copy of dmd is out of date. HEAD is passing the example. Closing because it works now.

--
October 08, 2017
https://issues.dlang.org/show_bug.cgi?id=16011

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--- Comment #6 from ag0aep6g@gmail.com ---
(In reply to Walter Bright from comment #5)
> Looks like my copy of dmd is out of date. HEAD is passing the example. Closing because it works now.

I can't confirm that. DMD64 D Compiler v2.076.1-b1-169-g5db88ac83 gives me "Error: struct test.S no size because of forward reference". Reopening.

--
December 17, 2019
https://issues.dlang.org/show_bug.cgi?id=16011

--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> ---
With master, this now produces:

std/traits.d(2713): Error: unable to determine fields of S because of forward
references
std/traits.d(3353): Error: template instance std.traits.FieldTypeTuple!(S)
error instantiating
std/typecons.d(6243):        instantiated from here: hasIndirections!(S)
test.d(6):        instantiated from here: RefCounted!(S,
cast(RefCountedAutoInitialize)1)

--