July 04, 2014 [Issue 13038] New: Calling to!String in the destructor | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13038 Issue ID: 13038 Summary: Calling to!String in the destructor Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nobody@puremagic.com Reporter: zhnavigator@mail.ru import std.stdio; import std.conv; class CDummy { static size_t counter; this() { counter++; } ~this() { counter--; writeln(to!string(counter)); // <= Ok!!! } } int main(string[] argv) { foreach(i; 0..10) { auto obj = new CDummy; destroy(obj); } return 0; } Ok!!! //--------------------------------------------- import std.stdio; import std.conv; class CDummy { static size_t counter; this() { counter++; } ~this() { counter--; writeln(to!string(counter)); //<== core.exception.InvalidMemoryOperationError } } int main(string[] argv) { foreach(i; 0..10) { auto obj = new CDummy; //destroy(obj); } return 0; } Crash!!! core.exception.InvalidMemoryOperationError //--------------------------------------------- import std.stdio; import std.conv; class CDummy { static size_t counter; this() { counter++; } ~this() { counter--; writeln(counter); // <== ok } } int main(string[] argv) { foreach(i; 0..10) { auto obj = new CDummy; //destroy(obj); } return 0; } Ok!!! -- |
Copyright © 1999-2021 by the D Language Foundation