This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/10707] c++ pretty-printer barfing on a vector
- From: "pmuldoon at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 30 Sep 2009 16:10:15 -0000
- Subject: [Bug python/10707] c++ pretty-printer barfing on a vector
- References: <20090929210334.10707.carlton@bactrian.org>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From pmuldoon at redhat dot com 2009-09-30 16:10 -------
I copied your program and added a return for clarity:
#include <string>
#include <vector>
int main() {
std::string s1("foo");
std::string s2("bar");
std::string s3("baz");
std::vector<std::string> strings;
strings.push_back(s1);
strings.push_back(s2);
strings.push_back(s3);
return 0;
}
so when on the "return 0" statement:
12 strings.push_back(s3);
(gdb)
14 return 0;
(gdb) p strings
$1 = std::vector of length 3, capacity 4 = {"foo", "bar", "baz"}
But once past that:
(gdb) n
15 }
(gdb) p strings
$2 = 0
I think the strings were garbage collected in your original case but not the
encapsulating vector. What's your opinion?
On the printed garbage, what you are seeing also is the string printer trying to
print just random memory. There's another bug relating to this:
http://sourceware.org/bugzilla/show_bug.cgi?id=10705
--
http://sourceware.org/bugzilla/show_bug.cgi?id=10707
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.