Comment #0 by default_357-line — 2020-03-09T10:13:39Z
Consider the code from issue 20650:
class Foo { ~this() { new int; } }
void main() { new Foo; }
This runs into core.exception.InvalidMemoryOperationError@src/core/exception.d(647): Invalid memory operation .
The reason is that the GC may not be invoked during finalizers, ie. when destructors are run. There is almost never a reason to do this; however, this should still be documented in the language spec at https://dlang.org/spec/class.html#destructors .
Comment #1 by robert.schadek — 2024-12-15T15:25:51Z