Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2226180/?format=api
{ "id": 2226180, "url": "http://patchwork.ozlabs.org/api/patches/2226180/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.2@forge-stage.sourceware.org/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.2@forge-stage.sourceware.org>", "list_archive_url": null, "date": "2026-04-22T10:25:11", "name": "[v1,02/12] libstdc++: Allow unordered_set assignment to assign to existing nodes", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "2d99b451f7a3635f94eacff2a7a30072b9af82e1", "submitter": { "id": 93210, "url": "http://patchwork.ozlabs.org/api/people/93210/?format=api", "name": "Jonathan Wakely via Sourceware Forge", "email": "forge-bot+redi@forge-stage.sourceware.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.2@forge-stage.sourceware.org/mbox/", "series": [ { "id": 500966, "url": "http://patchwork.ozlabs.org/api/series/500966/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500966", "date": "2026-04-22T10:25:11", "name": "WIP: libstdc++: Refactor hash table code", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500966/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226180/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226180/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org", "sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org", "server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0wWp41fkz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:32:06 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 89EE14B920D3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 10:32:03 +0000 (GMT)", "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id E6F604BBC085\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:26:14 +0000 (GMT)", "from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id C2C87405A1\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:26:14 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 89EE14B920D3", "OpenDKIM Filter v2.11.0 sourceware.org E6F604BBC085" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org E6F604BBC085", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org E6F604BBC085", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853575; cv=none;\n b=Y4R1c4p+ow3oQuDG1PBtvV3TX4BPVmebliJ3g2iGZdqasuYvROfHu0mD+cY+S30BAHqIm0/j8oZXJqLt1JMd1uE4Q0FIeVp75btZX2u3q0YElfI4ITl3uP1/E436TVNeD7SiazRwsTfczJKaEsJSxxfUBamQOWtcDMXAv8yj1Ow=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776853575; c=relaxed/simple;\n bh=RceIivGpD8f/7Dxn0Jrvb5mOEHVE+oFjp6EpykpYWqQ=;\n h=From:Date:Subject:MIME-Version:To:Message-ID;\n b=Vb5IuTrWCU9ECJaubiCpcKktbtbN9zcp4N/RgI4Kb8Z+gRzCRrAY6MWb11xAukz95r7gPyGCDKdRrRbsMxE/FcS4Ju3gaS+9RKzHI0ZfznSEawo07WJrKSSOE5AIWT4JnXmtwhc2JF1pWCvxLjPm00FKDfoSvaKrvHxYYLUAHuQ=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "Jonathan Wakely via Sourceware Forge\n <forge-bot+redi@forge-stage.sourceware.org>", "Date": "Wed, 22 Apr 2026 10:25:11 +0000", "Subject": "[PATCH v1 02/12] libstdc++: Allow unordered_set assignment to assign\n to existing nodes", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>", "Message-ID": "\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.2@forge-stage.sourceware.org>", "X-Mailer": "batrachomyomachia", "X-Requested-Reviewer": "fdumont", "X-Pull-Request-Organization": "gcc", "X-Pull-Request-Repository": "gcc-TEST", "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/15", "References": "\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.0@forge-stage.sourceware.org>", "In-Reply-To": "\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.0@forge-stage.sourceware.org>", "X-Patch-URL": "\n https://forge.sourceware.org/redi/gcc/commit/ddb8114a7c9e7454cfaf87e8f33ac806dcd8965d", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Reply-To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>, redi@gcc.gnu.org", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Jonathan Wakely <jwakely@redhat.com>\n\nCurrently the _ReuseOrAllocNode::operator(Args&&...) function always\ndestroys the value stored in recycled nodes and constructs a new value.\n\nThe _ReuseOrAllocNode type is only ever used for implementing\nassignment, either from another unordered container of the same type, or\nfrom std::initializer_list<value_type>. Consequently, the parameter pack\nArgs only ever consists of a single parameter or type const value_type&\nor value_type. We can replace the variadic parameter pack with a single\nforwarding reference parameter, and when the value_type is assignable\nfrom that type we can use assignment instead of destroying the existing\nvalue and then constructing a new one.\n\nUsing assignment is typically only possible for sets, because for maps\nthe value_type is std::pair<const key_type, mapped_type> and in most\ncases std::is_assignable_v<const key_type&, const key_type&> is false.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/hashtable_policy.h (_ReuseOrAllocNode::operator()):\n\tReplace parameter pack with a single parameter. Assign to\n\texisting value when possible.\n\t* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc:\n\tAdjust expected count of operations.\n\t* testsuite/23_containers/unordered_set/allocator/move_assign.cc:\n\tLikewise.\n\nReviewed-by: François Dumont <fdumont@gcc.gnu.org>\n---\n libstdc++-v3/include/bits/hashtable_policy.h | 37 +++++++++++++------\n .../allocator/move_assign.cc | 5 ++-\n .../unordered_set/allocator/move_assign.cc | 10 +++--\n 3 files changed, 35 insertions(+), 17 deletions(-)", "diff": "diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h\nindex b5f837e60619..7a3c66c37fd6 100644\n--- a/libstdc++-v3/include/bits/hashtable_policy.h\n+++ b/libstdc++-v3/include/bits/hashtable_policy.h\n@@ -172,24 +172,39 @@ namespace __detail\n ~_ReuseOrAllocNode()\n { _M_h._M_deallocate_nodes(_M_nodes); }\n \n- template<typename... _Args>\n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wc++17-extensions\" // if constexpr\n+ template<typename _Arg>\n \t__node_ptr\n-\toperator()(_Args&&... __args)\n+\toperator()(_Arg&& __arg)\n \t{\n \t if (!_M_nodes)\n-\t return _M_h._M_allocate_node(std::forward<_Args>(__args)...);\n+\t return _M_h._M_allocate_node(std::forward<_Arg>(__arg));\n+\n+\t using value_type = typename _NodeAlloc::value_type::value_type;\n \n \t __node_ptr __node = _M_nodes;\n-\t _M_nodes = _M_nodes->_M_next();\n-\t __node->_M_nxt = nullptr;\n-\t auto& __a = _M_h._M_node_allocator();\n-\t __node_alloc_traits::destroy(__a, __node->_M_valptr());\n-\t _NodePtrGuard<__hashtable_alloc, __node_ptr> __guard { _M_h, __node };\n-\t __node_alloc_traits::construct(__a, __node->_M_valptr(),\n-\t\t\t\t\t std::forward<_Args>(__args)...);\n-\t __guard._M_ptr = nullptr;\n+\t if constexpr (is_assignable<value_type&, _Arg>::value)\n+\t {\n+\t __node->_M_v() = std::forward<_Arg>(__arg);\n+\t _M_nodes = _M_nodes->_M_next();\n+\t __node->_M_nxt = nullptr;\n+\t }\n+\t else\n+\t {\n+\t _M_nodes = _M_nodes->_M_next();\n+\t __node->_M_nxt = nullptr;\n+\t auto& __a = _M_h._M_node_allocator();\n+\t __node_alloc_traits::destroy(__a, __node->_M_valptr());\n+\t _NodePtrGuard<__hashtable_alloc, __node_ptr>\n+\t\t__guard{ _M_h, __node };\n+\t __node_alloc_traits::construct(__a, __node->_M_valptr(),\n+\t\t\t\t\t std::forward<_Arg>(__arg));\n+\t __guard._M_ptr = nullptr;\n+\t }\n \t return __node;\n \t}\n+#pragma GCC diagnostic pop\n \n private:\n __node_ptr _M_nodes;\ndiff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc\nindex 50608ec443ff..6d00354902ee 100644\n--- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc\n+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc\n@@ -46,8 +46,9 @@ void test01()\n VERIFY( 1 == v1.get_allocator().get_personality() );\n VERIFY( 2 == v2.get_allocator().get_personality() );\n \n- VERIFY( counter_type::move_count == 1 );\n- VERIFY( counter_type::destructor_count == 2 );\n+ VERIFY( counter_type::move_count == 0 );\n+ // 1 element in v1 destroyed.\n+ VERIFY( counter_type::destructor_count == 1 );\n }\n \n void test02()\ndiff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc\nindex 677ea67d0ea7..6be70022705a 100644\n--- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc\n+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc\n@@ -52,8 +52,9 @@ void test01()\n VERIFY( 1 == v1.get_allocator().get_personality() );\n VERIFY( 2 == v2.get_allocator().get_personality() );\n \n- VERIFY( counter_type::move_count == 1 );\n- VERIFY( counter_type::destructor_count == 2 );\n+ VERIFY( counter_type::move_count == 0 );\n+ // 1 element in v1 destroyed.\n+ VERIFY( counter_type::destructor_count == 1 );\n }\n \n // Check there's nothing left allocated or constructed.\n@@ -130,8 +131,9 @@ void test03()\n VERIFY( 1 == v1.get_allocator().get_personality() );\n VERIFY( 2 == v2.get_allocator().get_personality() );\n \n- VERIFY( counter_type::move_count == 1 );\n- VERIFY( counter_type::destructor_count == i + 1 );\n+ VERIFY( counter_type::move_count == 0 );\n+ // (i - 1) elements in v2 destroyed, and 1 element in v1 destroyed.\n+ VERIFY( counter_type::destructor_count == i );\n }\n \n // Check there's nothing left allocated or constructed.\n", "prefixes": [ "v1", "02/12" ] }