clear bug?
Dan Olson
zans.is.for.cans at yahoo.com
Sun Sep 4 12:30:58 PDT 2011
Using dmd 2.054 on osx:
Calling a instance method after using clear() on an instance is giving
me a bus error. The instance fields look like they are cleared ok, just
can't safely call a method. I think this used to work after the object
was cleared, and was the reason for clear() over the deprecated delete.
Dan
=-=-=
Sample:
import std.stdio;
class A
{
string name = "none";
void print() {writeln(name);}
}
void main()
{
A a = new A;
a.print(); // none
a.name = "xyzzy";
a.print(); // xyzzy
clear(a);
writeln(a.name); // a is reinit to "none" as expected
a.print(); // bus error?
}
Output:
$ dmd clearbug.d
$ ./clearbug
none
xyzzy
none
Bus error
More information about the Digitalmars-d-learn
mailing list