https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65230

--- Comment #6 from Ulrich Drepper <drepper.fsp+rhbz at gmail dot com> ---
Created attachment 53410
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53410&action=edit
consistent pretty printing of contains

How about this patch?

I used the attached test case.  With the current code 'info locals' at the end
of the function prints:

t1 = empty std::tuple
t2 = std::tuple containing = {[0] = 0}
t3 = std::tuple containing = {[0] = 0, [1] = 0}
v1 = std::vector of length 0, capacity 0
v2 = std::vector of length 1, capacity 1 = {0}
v3 = std::vector of length 2, capacity 2 = {0, 0}
va1 = std::vector of length 0, capacity 0
va2 = std::vector of length 1, capacity 1 = {0}
va3 = std::vector of length 2, capacity 2 = {0, 0}
a1 = {_M_elems = {<No data fields>}}
a2 = {_M_elems = {0}}
a3 = {_M_elems = {0, 0}}
p1 = {first = 0, second = 0}
b1 = std::bitset
b2 = std::bitset
b3 = std::bitset
b4 = std::bitset = {[0] = 1}
b5 = std::bitset = {[70] = 1}

With the patch it prints:

t1 = std::tuple<> = {}
t2 = std::tuple<int> = {[0] = 0}
t3 = std::tuple<int, int> = {[0] = 0, [1] = 0}
v1 = std::vector<int> of length 0, capacity 0 = {}
v2 = std::vector<int> of length 1, capacity 1 = {0}
v3 = std::vector<int> of length 2, capacity 2 = {0, 0}
va1 = std::vector<int, va<int> > of length 0, capacity 0 = {}
va2 = std::vector<int, va<int> > of length 1, capacity 1 = {0}
va3 = std::vector<int, va<int> > of length 2, capacity 2 = {0, 0}
a1 = std::array<int, 0> = {}
a2 = std::array<int, 1> = {0}
a3 = std::array<int, 2> = {0, 0}
p1 = std::pair<int, int> = {[0] = 0, [1] = 0}
b1 = std::bitset<0> = {}
b2 = std::bitset<1> = {}
b3 = std::bitset<2> = {}
b4 = std::bitset<2> = {[0] = 1}
b5 = std::bitset<72> = {[70] = 1}

This is quite a change from before but I think quite consistent.  NB: also
tested with _GLIBXX_DEBUG.

There is one point I'm not sure about: should the std::vector printer
explicitly show the length (capacity is no question)?  This is the one
remaining inconsistency.  The tuple printer does not explicitly list the number
of elements.  On the other hand, to avoid making the output too long the
std::vector printer does not show the indeces and therefore the number of
elements cannot be see right away.  So, maybe leave it as is?

BTW: notice that I added a pretty printer for std::array and I also added code
to recognize a standard allocator template argument to std::vector (which in
this case is not shown).

Reply via email to