D - Call delete from destructor ?
- Silencer (32/32) Jan 29 2004 Why when I call delete from destructor of class B, my program is stopped...
- J Anderson (8/41) Jan 29 2004 Must be a Linux bug. Work for me in winXP .79.
Why when I call delete from destructor of class B, my program is stopped and
don't answer. It's a bug or feature ? (Compiled with dmd 0.79, 0.78 under linux)
Program output :
------------
B()
A()
~B()
----------
// Program listing
class A
{
this() { printf("A()\n"); }
~this() { printf("~A()\n"); }
}
class B
{
this() {
printf("B()\n");
m_a = new A;
}
~this() {
printf("~B()\n");
delete m_a; // Error ?!!!
}   
A m_a;
}
int main(char[][] args)
{
B b = new B;
delete b;
return 0;
}
 Jan 29 2004
Silencer wrote:
Why when I call delete from destructor of class B, my program is stopped and
don't answer. It's a bug or feature ? (Compiled with dmd 0.79, 0.78 under linux)
Program output :
------------
B()
A()
~B()
----------
// Program listing
class A
{
this() { printf("A()\n"); }
~this() { printf("~A()\n"); }
}
class B
{
this() {
printf("B()\n");
m_a = new A;
}
~this() {
printf("~B()\n");
delete m_a; // Error ?!!!
}   
A m_a;
}
int main(char[][] args)
{
B b = new B;
delete b;
return 0;
}
  
Must be a Linux bug.  Work for me in winXP .79.
B()
A()
~B()
~A()
-- 
-Anderson: http://badmama.com.au/~anderson/
 Jan 29 2004








 
  
  
  J Anderson <REMOVEanderson badmama.com.au>
 J Anderson <REMOVEanderson badmama.com.au>