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: [email protected]
Reporter: [email protected]
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!!!
--