public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103086] [11 Regression] std::unique_ptr printer gets confused by [[no_unique_address]] in tuple Date: Tue, 23 Nov 2021 21:18:01 +0000 [thread overview] Message-ID: <bug-103086-4-nXtiyCGf4o@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103086-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103086 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:fa4a8f3faaa1172b103c6a148a7830e7e6375cc3 commit r11-9271-gfa4a8f3faaa1172b103c6a148a7830e7e6375cc3 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Nov 4 22:50:02 2021 +0000 libstdc++: Fix pretty printing of std::unique_ptr [PR103086] Since std::tuple started using [[no_unique_address]] the tuple<T*, D> member of std::unique_ptr<T, D> has two _M_head_impl subobjects, in different base classes. That means this printer code is ambiguous: tuple_head_type = tuple_impl_type.fields()[1].type # _Head_base head_field = tuple_head_type.fields()[0] if head_field.name == '_M_head_impl': self.pointer = tuple_member['_M_head_impl'] In older versions of GDB it happened to work by chance, because GDB returned the last _M_head_impl member and std::tuple's base classes are stored in reverse order, so the last one was the T* element of the tuple. Since GDB 11 it returns the first _M_head_impl, which is the deleter element. The fix is for the printer to stop using an ambiguous field name and cast the tuple to the correct base class before accessing the _M_head_impl member. Instead of fixing this in both UniquePointerPrinter and StdPathPrinter a new unique_ptr_get function is defined to do it correctly. That is defined in terms of new tuple_get and _tuple_impl_get functions. It would be possible to reuse _tuple_impl_get to access each element in StdTuplePrinter._iterator.__next__, but that already does the correct casting, and wouldn't be much simpler anyway. libstdc++-v3/ChangeLog: PR libstdc++/103086 * python/libstdcxx/v6/printers.py (_tuple_impl_get): New helper for accessing the tuple element stored in a _Tuple_impl node. (tuple_get): New function for accessing a tuple element. (unique_ptr_get): New function for accessing a unique_ptr. (UniquePointerPrinter, StdPathPrinter): Use unique_ptr_get. * python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker): Cast tuple to its base class before accessing _M_head_impl. (cherry picked from commit a634928f5c8a281442ac8f5fb1636aed048ed72c)
next prev parent reply other threads:[~2021-11-23 21:18 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-04 17:29 [Bug libstdc++/103086] New: [11/12 " redi at gcc dot gnu.org 2021-11-04 17:29 ` [Bug libstdc++/103086] " redi at gcc dot gnu.org 2021-11-04 21:30 ` redi at gcc dot gnu.org 2021-11-04 23:06 ` cvs-commit at gcc dot gnu.org 2021-11-04 23:10 ` redi at gcc dot gnu.org 2021-11-05 7:24 ` [Bug libstdc++/103086] [11 " rguenth at gcc dot gnu.org 2021-11-23 17:33 ` redi at gcc dot gnu.org 2021-11-23 21:18 ` cvs-commit at gcc dot gnu.org [this message] 2021-11-23 21:18 ` redi at gcc dot gnu.org 2021-11-23 21:41 ` cvs-commit at gcc dot gnu.org 2021-11-24 11:50 ` cvs-commit at gcc dot gnu.org 2022-01-05 17:53 ` cvs-commit at gcc dot gnu.org 2022-01-05 17:53 ` cvs-commit at gcc dot gnu.org 2022-01-05 17:56 ` redi at gcc dot gnu.org
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-103086-4-nXtiyCGf4o@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: linkBe 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).