[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

g++



Hi everyone!

May be I'm wrong and need to upgrade compiler, but yesterday
I was surprised with segfault in the following well-compiled code.

/******************************************************************************
   Strange thing, but this piece of code may initiate segfault
   near push_back in while. Is there an error in vector?
   gcc version 2.95.2 20000220 (Debian GNU/Linux)
   
   void f()
   {

        vector<string> paths;
        paths.push_back("1");

        cout << "loop..." << endl;

        vector<string>::iterator p = paths.begin();
        while (p != paths.end()) {
                cout << "\t" << *p << endl;
                
                paths.push_back(p, "2");
                ^^^^^^^^^^^^^^^^^^^^^^^^
                this is the place of segfault
                
                ++p;
        }
                
        cout << "end..." << endl;
   }

******************************************************************************/

Please include CC: to me in your replies.



-- 
Andrew Saunders


-- 
To UNSUBSCRIBE, email to debian-gcc-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: