From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8E25A3858407; Thu, 4 Aug 2022 18:16:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E25A3858407 From: "drepper.fsp+rhbz at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: drepper.fsp+rhbz at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2022 18:16:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65230 --- Comment #6 from Ulrich Drepper --- Created attachment 53410 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53410&action=3Dedit 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 =3D empty std::tuple t2 =3D std::tuple containing =3D {[0] =3D 0} t3 =3D std::tuple containing =3D {[0] =3D 0, [1] =3D 0} v1 =3D std::vector of length 0, capacity 0 v2 =3D std::vector of length 1, capacity 1 =3D {0} v3 =3D std::vector of length 2, capacity 2 =3D {0, 0} va1 =3D std::vector of length 0, capacity 0 va2 =3D std::vector of length 1, capacity 1 =3D {0} va3 =3D std::vector of length 2, capacity 2 =3D {0, 0} a1 =3D {_M_elems =3D {}} a2 =3D {_M_elems =3D {0}} a3 =3D {_M_elems =3D {0, 0}} p1 =3D {first =3D 0, second =3D 0} b1 =3D std::bitset b2 =3D std::bitset b3 =3D std::bitset b4 =3D std::bitset =3D {[0] =3D 1} b5 =3D std::bitset =3D {[70] =3D 1} With the patch it prints: t1 =3D std::tuple<> =3D {} t2 =3D std::tuple =3D {[0] =3D 0} t3 =3D std::tuple =3D {[0] =3D 0, [1] =3D 0} v1 =3D std::vector of length 0, capacity 0 =3D {} v2 =3D std::vector of length 1, capacity 1 =3D {0} v3 =3D std::vector of length 2, capacity 2 =3D {0, 0} va1 =3D std::vector > of length 0, capacity 0 =3D {} va2 =3D std::vector > of length 1, capacity 1 =3D {0} va3 =3D std::vector > of length 2, capacity 2 =3D {0, 0} a1 =3D std::array =3D {} a2 =3D std::array =3D {0} a3 =3D std::array =3D {0, 0} p1 =3D std::pair =3D {[0] =3D 0, [1] =3D 0} b1 =3D std::bitset<0> =3D {} b2 =3D std::bitset<1> =3D {} b3 =3D std::bitset<2> =3D {} b4 =3D std::bitset<2> =3D {[0] =3D 1} b5 =3D std::bitset<72> =3D {[70] =3D 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 nu= mber 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 c= ode to recognize a standard allocator template argument to std::vector (which in this case is not shown).=