public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "drepper.fsp+rhbz at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/65230] pretty-print inconsistent output for similar objects
Date: Thu, 04 Aug 2022 18:16:50 +0000	[thread overview]
Message-ID: <bug-65230-4-6lVeWsJzbK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65230-4@http.gcc.gnu.org/bugzilla/>

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

  parent reply	other threads:[~2022-08-04 18:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27  6:46 [Bug libstdc++/65230] New: " msebor at gcc dot gnu.org
2015-02-27  8:53 ` [Bug libstdc++/65230] " redi at gcc dot gnu.org
2022-08-04 11:44 ` drepper.fsp+rhbz at gmail dot com
2022-08-04 11:47 ` drepper.fsp+rhbz at gmail dot com
2022-08-04 11:48 ` drepper.fsp+rhbz at gmail dot com
2022-08-04 11:50 ` drepper.fsp+rhbz at gmail dot com
2022-08-04 18:16 ` drepper.fsp+rhbz at gmail dot com [this message]
2022-08-04 18:35 ` redi at gcc dot gnu.org
2022-08-05 16:26 ` drepper.fsp+rhbz at gmail dot com
2022-08-05 16:27 ` drepper.fsp+rhbz at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65230-4-6lVeWsJzbK@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).