Comment #0 by verylonglogin.reg — 2013-02-27T01:40:35Z
---
extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true);
class A
{
class B
{
int n;
~this() { n = 7; }
}
}
void main()
{
A a = new A;
A.B b = a.new B;
rt_finalize2(cast(void*) a);
assert(b.n == 7); // fails
}
---
I see no reasons for such "orphan" class to be "alive" as we even doesn't have "isFinalized" function for object checking to be finalized.
Comment #1 by verylonglogin.reg — 2013-02-27T01:43:31Z
Damn, `n` in example must not be a field. Is should be a global TLS variable.
Comment #2 by yebblies — 2014-07-24T14:45:54Z
Unless I'm mistaken, you're asking for the GC to walk the heap and finalize all nested class instances when an object dies. This is most certainly an enhancement. Your code is working as designed - it is not valid to finalize/delete a class and then reference it, implicitly or otherwise.
Comment #3 by yebblies — 2014-07-24T14:46:30Z
Also, this is a druntime issue not a compiler one.
Comment #4 by robert.schadek — 2024-12-07T13:32:16Z