digitalmars.D.bugs - [Issue 17230] New: Destroy forward reference error
- via Digitalmars-d-bugs (48/48) Feb 27 2017 https://issues.dlang.org/show_bug.cgi?id=17230
https://issues.dlang.org/show_bug.cgi?id=17230 Issue ID: 17230 Summary: Destroy forward reference error Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: radu.racariu gmail.com This reduced test: -------------code------------- struct A { B b; } struct B { Wrap!A val; } struct Wrap(T) { ~this() { destroy(*t); destroy(t); } T* t; } -------------code------------- compiler: dmd 2.073.1 fails with: == Error: struct f909.A no size because of forward reference /d934/f909.d(14): Error: template instance object.destroy!(A) error instantiating /d934/f909.d(8): instantiated from here: Wrap!(A) == As per http://forum.dlang.org/thread/uplymqtaxubgkxwzacrz forum.dlang.org and this http://ddili.org/ders/d.en/memory.html#ix_memory.destroy - it looks that destroy needs to be called by dereferencing the pointer in order for the T dtor to be called. The fwd ref error makes it impossible to use destroy. The workaround is to use delete t to get the dtor called without deref, but it is hacky! --
Feb 27 2017