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++/31735] Problem using <string> STL



------- Comment #1 from pcarlini at suse dot de  2007-04-28 19:15 -------
This code is illegal, compile it with -D_GLIBCXX_DEBUG and the run it and you
will see. In a nutshell:

        int  n, nn; 
        string vector[54], word;

        cin >> nn;
        for (int i=0; i<nn; i++){
                cin >> word;                    
                for (int j=0; j<word.size(); j++){ vector[i][j] = word[j];}

You are assigning to position j of string i of vector, but that string is still
zero-sized at that point.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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