Bug 11204 – Struct is destroyed before constructed

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-09T02:59:00Z
Last change time
2013-10-10T05:14:26Z
Assigned to
nobody
Creator
samukha

Comments

Comment #0 by samukha — 2013-10-09T02:59:12Z
This illustrates what I meant in bug 10186, comment 6: struct S { @disable this(); bool cted; this(int x) { cted = true; } static int destroyedBeforeConstructed; ~this() { if (!cted) destroyedBeforeConstructed++; } } class A { S s; this() { s = S(1); } } void main() { auto a = new A; assert(S.destroyedBeforeConstructed == 0); } Assertion fails because assignment triggers destruction of a struct that has never been constructed. With this one, object lifetime management remains fatally broken.
Comment #1 by code — 2013-10-09T12:44:10Z
This is most likely a duplicate of: http://d.puremagic.com/issues/show_bug.cgi?id=8360
Comment #2 by k.hara.pg — 2013-10-10T05:14:26Z
*** This issue has been marked as a duplicate of issue 9665 ***