CC gcc-patches On Wed, 27 Jul 2022 at 17:40, Ulrich Drepper via Libstdc++ <libstd...@gcc.gnu.org> wrote: > > The current tuple pretty printer shows for this variable > > std::tuple<int,int,int> a{1,2,3}; > > the following output: > > (gdb) p a > $1 = std::tuple containing = {[1] = 1, [2] = 2, [3] = 3} > > I find this quite irritating because the indices don't match the > std::get template parameters. In a large tuple or arrays of tuples > which are less readable than this simple example this becomes an even > larger problem. How about the following simple patch which brings the > indices in line?
I think this makes sense, want to push it? > > --- a/libstdc++-v3/python/libstdcxx/v6/printers.py > +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py > @@ -611,9 +611,9 @@ class StdTuplePrinter: > # the value "as is". > fields = impl.type.fields () > if len (fields) < 1 or fields[0].name != "_M_head_impl": > - return ('[%d]' % self.count, impl) > + return ('[%d]' % (self.count - 1), impl) > else: > - return ('[%d]' % self.count, impl['_M_head_impl']) > + return ('[%d]' % (self.count - 1), impl['_M_head_impl']) > > def __init__ (self, typename, val): > self.typename = strip_versioned_namespace(typename) >