public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65230] New: pretty-print inconsistent output for similar objects
@ 2015-02-27  6:46 msebor at gcc dot gnu.org
  2015-02-27  8:53 ` [Bug libstdc++/65230] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-02-27  6:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65230
           Summary: pretty-print inconsistent output for similar objects
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org

The libstdc++ pretty printer produces inconsistent output for objects with
similar properties, making it more difficult than necessary to interpret.   For
example, an "empty" bitset object (one consisting of no bits, or one with no
bits set) is printed simply as "std::bitset" while an empty std::tuple<> is
printed as "empty std::tuple".  A std::vector<bool> of size 0 is printed to
include its size and capacity, while a non-empty vector<bool> also includes its
elements. An example is below.

I'd like to propose that the value of an empty object be printed as "{ }"
regardless of its type.  I.e., a std::bitset<0> as "std::bitset { }", a
std::tuple<> as "std::tuple<> { }", and an empty std::vector<T> as
"std::vector<T> of length 0, capacity N = { }"

$ g++ -g -std=c++11 t.cpp && gdb -batch -ex "b foo" -ex "r" -ex "p b0" -ex "p
b1" -ex "p t0" -ex "p t1" -ex "p v0" -ex "p v1" -q a.out
Breakpoint 1 at 0x100008a8: file t.cpp, line 9.

Python Exception <class 'gdb.error'> There is no member or method named _M_w.: 
Breakpoint 1, foo(std::bitset<0ul>, std::bitset<1ul>, std::tuple<>,
std::tuple<int>, std::vector<bool, std::allocator<bool> >, std::vector<bool,
std::allocator<bool> >) (b0=std::bitset, b1=std::bitset, t0=empty std::tuple,
t1=std::tuple containing = {...}, v0=std::vector<bool> of length 0, capacity 0,
v1=std::vector<bool> of length 1, capacity 64 = {...}) at t.cpp:9
9    }
Python Exception <class 'gdb.error'> There is no member or method named _M_w.: 
$1 = std::bitset
$2 = std::bitset
$3 = empty std::tuple
$4 = std::tuple containing = {[1] = 0}
$5 = std::vector<bool> of length 0, capacity 0
$6 = std::vector<bool> of length 1, capacity 64 = {0}


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-08-05 16:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27  6:46 [Bug libstdc++/65230] New: pretty-print inconsistent output for similar objects 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
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

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