Bug 16011 – [REG2.068] recursive RefCounted used to work

Status
REOPENED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-10T21:56:57Z
Last change time
2024-12-13T18:47:41Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
ag0aep6g
Moved to GitHub: dmd#19121 →

Comments

Comment #0 by ag0aep6g — 2016-05-10T21:56:57Z
See also this post to D.learn by Lodovico Giaretta: http://forum.dlang.org/post/[email protected] ---- import std.typecons: RefCounted; struct S { int x; RefCounted!S s; } void main() { S s; s.x = 1; s.s.x = 2; s.s.s.x = 3; assert(s.x == 1); assert(s.s.x == 2); assert(s.s.s.x == 3); } ---- 2.067.1: Compiles and passes asserts. 2.068.2, 2.069.2: segfault 2.070.2, 2.071.0: "no size yet for forward reference" errors git master (bc74f4a): "std/typecons.d(4739): Error: forward reference to (*this._store)._payload" 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.
Comment #1 by ag0aep6g — 2016-05-10T21:59:08Z
(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.
Comment #2 by k.hara.pg — 2016-05-13T20:55:07Z
I concluded this is a compiler issue. https://github.com/dlang/dmd/pull/5773
Comment #3 by bugzilla — 2017-10-08T05:03:23Z
Compiling this now gives the following error: [email protected](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; }
Comment #4 by bugzilla — 2017-10-08T05:30:46Z
Comment #5 by bugzilla — 2017-10-08T06:21:59Z
Looks like my copy of dmd is out of date. HEAD is passing the example. Closing because it works now.
Comment #6 by ag0aep6g — 2017-10-08T08:55:49Z
(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.
Comment #7 by bugzilla — 2019-12-17T10:25:54Z
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)
Comment #8 by robert.schadek — 2024-12-13T18:47:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19121 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB