This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31735] Problem using <string> STL
- From: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Apr 2007 18:15:34 -0000
- Subject: [Bug c++/31735] Problem using <string> STL
- References: <bug-31735-14477@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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