January 25, 2015 [Issue 5895] Object.clear() doesn't work as expected for pointers to structs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5895 AndyC <andy@squeakycode.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andy@squeakycode.net --- Comment #2 from AndyC <andy@squeakycode.net> --- This might be closeable. object.close() is deprecated and the compiler warns you should use destroy() instead. However: import std.stdio; struct Bar { ~this() { writeln("bye"); } } void main() { Bar *b = new Bar(); destroy(b); } Still doesnt call the destructor ... but that's because it needs to be called as: destroy(*b) There is form discussion here: http://forum.dlang.org/thread/fpvoxowzicqoqlitadyj@forum.dlang.org I wonder if there is any way the compiler can warn on: Bar *b = new Bar(); destroy(b); If so I think that should be a new bug, and this one closed. -- |
January 26, 2015 [Issue 5895] Object.clear() doesn't work as expected for pointers to structs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=5895 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution|--- |INVALID --- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> --- While the behavior may be unintuitive, the distinction is intended. Class references are actually the oddball behavior, but there is no way to separate the class data vs. the reference. In terms of replacing delete, destroy is not that, although it is part of it. I think in order for this to be "fixed" it needs to be in a DIP, or at least framed a different way. -- |
Copyright © 1999-2021 by the D Language Foundation