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++/114401] libstdc++ allocator destructor omitted when reinserting node_handle into tree- and hashtable-based containers
Date: Wed, 03 Apr 2024 10:46:51 +0000	[thread overview]
Message-ID: <bug-114401-4-ncD8ts84vx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114401-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:47ebdbe5bf71d9eb260359b6aceb5cb071d97acd

commit r13-8570-g47ebdbe5bf71d9eb260359b6aceb5cb071d97acd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Mar 21 13:25:15 2024 +0000

    libstdc++: Destroy allocators in re-inserted container nodes [PR114401]

    The allocator objects in container node handles were not being destroyed
    after the node was re-inserted into a container. They are stored in a
    union and so need to be explicitly destroyed when the node becomes
    empty. The containers were zeroing the node handle's pointer, which
    makes it empty, causing the handle's destructor to think there's nothing
    to clean up.

    Add a new member function to the node handle which destroys the
    allocator and zeros the pointer. Change the containers to call that
    instead of just changing the pointer manually.

    We can also remove the _M_empty member of the union which is not
    necessary.

    libstdc++-v3/ChangeLog:

            PR libstdc++/114401
            * include/bits/hashtable.h (_Hashtable::_M_reinsert_node): Call
            release() on node handle instead of just zeroing its pointer.
            (_Hashtable::_M_reinsert_node_multi): Likewise.
            (_Hashtable::_M_merge_unique): Likewise.
            (_Hashtable::_M_merge_multi): Likewise.
            * include/bits/node_handle.h (_Node_handle_common::release()):
            New member function.
            (_Node_handle_common::_Optional_alloc::_M_empty): Remove
            unnecessary union member.
            (_Node_handle_common): Declare _Hashtable as a friend.
            * include/bits/stl_tree.h (_Rb_tree::_M_reinsert_node_unique):
            Call release() on node handle instead of just zeroing its
            pointer.
            (_Rb_tree::_M_reinsert_node_equal): Likewise.
            (_Rb_tree::_M_reinsert_node_hint_unique): Likewise.
            (_Rb_tree::_M_reinsert_node_hint_equal): Likewise.
            * testsuite/23_containers/multiset/modifiers/114401.cc: New test.
            * testsuite/23_containers/set/modifiers/114401.cc: New test.
            * testsuite/23_containers/unordered_multiset/modifiers/114401.cc:
New test.
            * testsuite/23_containers/unordered_set/modifiers/114401.cc: New
test.

    (cherry picked from commit c2e28df90a1640cebadef6c6c8ab5ea964071bb1)

      parent reply	other threads:[~2024-04-03 10:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  8:35 [Bug libstdc++/114401] New: " jblair149 at gmail dot com
2024-03-20 11:23 ` [Bug libstdc++/114401] " redi at gcc dot gnu.org
2024-03-20 14:46 ` redi at gcc dot gnu.org
2024-03-20 14:49 ` redi at gcc dot gnu.org
2024-03-21 12:06 ` redi at gcc dot gnu.org
2024-03-22 22:51 ` cvs-commit at gcc dot gnu.org
2024-03-22 22:55 ` redi at gcc dot gnu.org
2024-04-03 10:46 ` cvs-commit at gcc dot gnu.org [this message]

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-114401-4-ncD8ts84vx@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).