typeid + toString = runtime error
Ali Çehreli
acehreli at yahoo.com
Sun Dec 30 08:04:48 PST 2012
On 12/30/2012 07:32 AM, Zhenya wrote:
> Hi!
> Explain me please why this code fails in runtime:
>
> import std.stdio;
>
> class Foo
> {
> ~this() {writeln(typeid(this).toString ~ "is dead");}
> }
>
> void main()
> {
> new Foo;
> }
>
> Application error:
> core.exception.InvalidMemoryOperationError
My guess is that by the time that destructor is executed, the runtime
has been shut down sufficiently that the ~ operator cannot work. The
following has the same error:
import std.stdio;
string foo()
{
return "abc";
}
class Foo
{
~this() {writeln(foo() ~ "xyz");}
}
void main()
{
new Foo;
}
Ali
More information about the Digitalmars-d-learn
mailing list