This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60213] Weird crash when delete an object


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60213

--- Comment #1 from hubert.vansteenhuyse at freecode dot be ---
struct A {
 A *a[2];
 A() { a[0] = 0; a[1] = 0; }
 ~A(){ if(a[0]) delete a[0];  if(a[1]) delete a[1];
}

void main(){
A *a = new A();
a->a[0] = new A();
a->a[1] = new A();

delete a; //<----<< crash, because adress of a == address of a.a[0] :(
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]