Bug 20651 – Document that destructors may not allocate memory

Status
NEW
Severity
enhancement
Priority
P4
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-03-09T10:13:39Z
Last change time
2024-12-15T15:25:51Z
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dlang.org#3982 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/3982 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB