Bug 15571 – .dup is incompatible with self referencing structs

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-01-16T19:42:09Z
Last change time
2024-12-13T18:46:34Z
Assigned to
No Owner
Creator
foldenyi.tamas
Moved to GitHub: dmd#19090 →

Comments

Comment #0 by foldenyi.tamas — 2016-01-16T19:42:09Z
.dup is not compatible with self-referencing structs: This code does not compile due to the .dup operation: template Wrapper(T) { struct Wrapper { private T[] _holder; this(this) { _holder = _holder.dup; } } } unittest { struct Node { Wrapper!Node next; }; }
Comment #1 by ag0aep6g — 2016-01-16T23:22:45Z
Compiles fine when Node is not in a unittest (or other kind of function): ---- template Wrapper(T) { struct Wrapper { private T[] _holder; this(this) { _holder = _holder.dup; } } } struct Node { Wrapper!Node next; } ----
Comment #2 by schuetzm — 2016-01-19T18:32:30Z
Here's the error message: /home/marc/d/druntime/import/object.d(3361): Error: struct xx.__unittestL10_1.Node no size yet for forward reference /home/marc/d/druntime/import/object.d(3361): Error: struct xx.__unittestL10_1.Node no size yet for forward reference xx.d(11): Error: struct xx.__unittestL10_1.Node no size yet for forward reference /home/marc/d/druntime/import/object.d(3378): Error: struct xx.__unittestL10_1.Node no size yet for forward reference /home/marc/d/druntime/import/object.d(3365): Error: template instance object._rawDup!(Node) error instantiating /home/marc/d/druntime/import/object.d(3352): instantiated from here: _dup!(const(Node), Node) /home/marc/d/druntime/import/object.d(3319): instantiated from here: _trustedDup!(const(Node), Node) xx.d(5): instantiated from here: dup!(Node) xx.d(12): instantiated from here: Wrapper!(Node)
Comment #3 by robert.schadek — 2024-12-13T18:46:34Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19090 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB