public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem with list.
@ 2005-09-23 10:50 Aseem Rastogi
  2005-09-23 11:29 ` John Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: Aseem Rastogi @ 2005-09-23 10:50 UTC (permalink / raw)
  To: gcc-help

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-09-23 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-23 10:50 Problem with list Aseem Rastogi
2005-09-23 11:29 ` John Love-Jensen
2005-09-23 12:17   ` Aseem Rastogi
2005-09-23 12:53     ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).