This is the mail archive of the gcc-help@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]

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.



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