[Issue 14860] New: Destructor is not called for block assignment
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Aug 1 19:03:56 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14860
Issue ID: 14860
Summary: Destructor is not called for block assignment
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
It's similar to 14815.
From: http://forum.dlang.org/thread/wkwzokdccfbjnzeqmqmz@forum.dlang.org
uint dtorCount;
struct S
{
uint x;
void opAssign(const ref S rhs) { assert(false, "Not called"); }
~this() { ++dtorCount; }
}
void main()
{
S[] a;
a.length = 1;
a[0].x = 42; // Some random non-init value
a[] = S.init;
assert(a[0].x == 0); // As expected, the value has been reset
assert(dtorCount == 0); // Passes?!?
}
--
More information about the Digitalmars-d-bugs
mailing list