]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Adjust index number of tuple pretty printer
authorUlrich Drepper <drepper@gmail.com>
Thu, 4 Aug 2022 11:18:05 +0000 (13:18 +0200)
committerUlrich Drepper <drepper@gmail.com>
Thu, 4 Aug 2022 11:18:05 +0000 (13:18 +0200)
The tuple pretty printer uses 1-based indeces which is quite confusing
considering the access to the same values with the std::get functions
uses 0-based indeces.  This patch changes the pretty printer since
this is not a guaranteed API.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (class StdTuplePrinter): Use
zero-based indeces just like std:get takes.

libstdc++-v3/python/libstdcxx/v6/printers.py

index 17c33c1e54f2460f93ef7699e898981c4ca299ab..d70c8d5d616e7cb7f4c5d5d94a893779fa5d33c3 100644 (file)
@@ -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)