Dear Maintainer,
it seems pretty-printing std::lists is broken sometimes. Consider the following
C++11 program:
-------- 8< --------
#include <iostream>
#include <string>
#include <list>
class Msg {
public:
std::list<std::string> params_;
std::list<std::string> params() const { return params_; }
Msg(const std::list<std::string>& params) : params_(params) {
}
};
int main() {
std::list<std::string> p = { "foo", "bar", "baz" };
Msg msg(p); // (A)
std::cout << msg.params().size() << std::endl; // prints 3
auto asdf = msg.params(); // (B)
for (auto a : msg.params()) {
std::cout << a << std::endl; // prints foo, bar, baz
}
return 0;
}
-------- >8 --------
When I step through the program, after line (A), printing msg.params_ yields
the correct list contents, but printing msg.params() yields garbled characters
and a list with > 31 entries (see attached gdb log). Further investigation shows
that when I try to print msg.params().size(), I get "Attempt to take address of
value not located in memory.", and printing the variable asdf in line (B) also
yields the correct results.
All of this also happens with std::list<int> and std::list<double>, but not with
std::maps, std::vectors or std::sets. In any case, all values are printed
correctly to the console, so the underlying memory is apparently fine.
Thanks for listening,
- Roland