This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem with list.
- From: Aseem Rastogi <aseem at india dot tejasnetworks dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 23 Sep 2005 16:28:44 +0530
- Subject: Problem with list.
Hi,
Can somebody explain the following behaviour? Even after deleting the
member of list, I am not getting segmentation fault at last line (as
expected). Rather foo () output is what comes out.
#include<list>
list<A*> l;
int main ()
{
A* a = new A ();
cout << a->foo () << endl; // Prints 0 which is OK
l.push_back (a);
for (list<A*>::iterator it = l.begin (); it != l.end (); it++) {
delete (*it);
}
cout << a->foo () << endl; // Should give Segmentation Fault
but its not !!!! Prints 0 which is not OK.
}
Regards,
Aseem.
--
The end is always good. If it's not good, it's not the end.