Bug 13059 – Delete uses destructor rather than the delete operator

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-06T19:58:22Z
Last change time
2019-08-11T15:54:49Z
Assigned to
No Owner
Creator
Orvid King

Comments

Comment #0 by blah38621 — 2014-07-06T19:58:22Z
Currently, if you define a destructor on a struct, allocate an instance of that struct on the heap, and then attempt to use the delete keyword to destroy and then free the memory, it will instead only call the destructor, just as-if you had defined a delete operator, this is not mentioned in the spec, and was only noticed because it caused double finalization when I added support to the GC for calling struct's destructors.
Comment #1 by bearophile_hugs — 2014-07-06T20:13:16Z
(In reply to Orvid King from comment #0) > if you define a destructor on a struct, allocate an instance of that > struct on the heap, and then attempt to use the delete keyword to The delete keyword is deprecated, don't use it.
Comment #2 by blah38621 — 2014-07-06T23:51:47Z
Unfortunately it's not officially deprecated, the only warning or deprecation error currently given by DMD for delete is for AAs. And it's not me that's using it, but rather sdtor.d in the dmd test suite.
Comment #3 by pro.mathias.lang — 2019-08-11T15:54:49Z
`delete` keyword is now officially deprecated.