This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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 python/10707] c++ pretty-printer barfing on a vector


------- 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.


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