Missing destructor call using clear and base interface ref.
Roberto Delfiore
roberto.delfiore at gmail.com
Mon Aug 6 06:59:44 PDT 2012
See the following code:
interface A{
}
class B : A{
this(string name){this.name = name;}
~this(){
writefln("Destructor %s", name);
}
string name;
}
void main(){
B b0 = new B("b0");
B b1 = new B("b1");
A a = b0;
clear(a);
clear(b1);
}
Output:
Destructor b1
dmd 2.059
Why is the B destructor not invoked in the first clear?
Expected output:
Destructor b0
Destructor b1
More information about the Digitalmars-d-learn
mailing list