Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2226281/?format=api
{ "id": 2226281, "url": "http://patchwork.ozlabs.org/api/patches/2226281/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhubjjpeho.gcc.gcc-TEST.redi.25.1.1@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.hhubjjpeho.gcc.gcc-TEST.redi.25.1.1@forge-stage.sourceware.org>", "list_archive_url": null, "date": "2026-04-22T10:36:18", "name": "[v1,1/4] libstdc++: Refactor std::list::size() for cxx11 ABI", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ac48d44ad93246b5e9d32c3ffba519fe5dc809c5", "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.hhubjjpeho.gcc.gcc-TEST.redi.25.1.1@forge-stage.sourceware.org/mbox/", "series": [ { "id": 500985, "url": "http://patchwork.ozlabs.org/api/series/500985/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500985", "date": "2026-04-22T10:36:19", "name": "libstdc++: Add fancy pointer support to std::list and std::forward_list [PR57272]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500985/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226281/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226281/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 4g0xHc287mz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 21:06:36 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 78FA44BB3BC5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 11:06:34 +0000 (GMT)", "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 11CA848FF194\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:37:13 +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 E04FB42B56\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:37:12 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 78FA44BB3BC5", "OpenDKIM Filter v2.11.0 sourceware.org 11CA848FF194" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 11CA848FF194", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 11CA848FF194", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776854233; cv=none;\n b=JoNKyhwf087mvNWIUx4wPgMxc8rVljPY6IO5VGOg4GE59g3WX6yFhMb+iQ5rbPeiFH2g9MSqKBosz4cJoyyMOIk0HUOUKq4pLobvNwchWPSf1t5W9PJ0uByb69BZxGylcMYZn6Sj/W8CWM15M61pDo/pHjz82RH3R7h2YbZ+Zq8=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776854233; c=relaxed/simple;\n bh=vO8gmVk9HS4T0tbfy2oqtPHx0NOwlp5d72WG7RXykS0=;\n h=From:Date:Subject:To:Message-ID;\n b=xdrxoCfeH28pENMeOG3oGzSndzpoaWe6rimWaz2CNRFKH276DAqwb6nL/hpRQItlOlWsIjkkai+nzN7Luvlu/tbJgP+V1fwGqaGIkHC9H/7Nmnxl9q6RLtOzQ3M5+aDzu8Ui8vKrJyO/OaO+lz+w8AUqNGS3etzHRfmuOgaHRrE=", "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:36:18 +0000", "Subject": "[PATCH v1 1/4] libstdc++: Refactor std::list::size() for cxx11 ABI", "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>", "Message-ID": "\n <bmm.hhubjjpeho.gcc.gcc-TEST.redi.25.1.1@forge-stage.sourceware.org>", "X-Mailer": "batrachomyomachia", "X-Pull-Request-Organization": "gcc", "X-Pull-Request-Repository": "gcc-TEST", "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/25", "References": "\n <bmm.hhubjjpeho.gcc.gcc-TEST.redi.25.1.0@forge-stage.sourceware.org>", "In-Reply-To": "\n <bmm.hhubjjpeho.gcc.gcc-TEST.redi.25.1.0@forge-stage.sourceware.org>", "X-Patch-URL": "\n https://forge.sourceware.org/redi/gcc/commit/28297cd9bf31930678ccc5ea03688ee6e2551b15", "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\nRemove some preprocessor conditionals by moving the _M_size member for\nthe cxx11 ABI into a new base class, which is empty for the gcc4-compat\nABI.\n\nMove some unused members that are only retained for ABI compatibility to\nthe end of _List_base and add an explanatory comment. Stop using\nlist::_M_node_count and list::_D_distance and then move them to the end\nof std::list with a comment too.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/stl_list.h (_List_size): New struct.\n\t(_List_node_header): Replace _M_size member with _List_size base\n\tclass.\n\t(_List_node_header(_List_node_header&&)): Replace explicit uses\n\tof _M_size with initializing the base.\n\t(_List_node_header::_M_init): Likewise.\n\t(_List_base::_S_distance, _List_base::_M_distance)\n\t(_List_base::_M_node_count): Move to end of class body and add\n\tcomment.\n\t(list::_S_distance, list::_M_node_count): Likewise.\n\t(list::size): Inline _M_node_count effects to here.\n\t(list::splice(iterator, list&, iterator, iterator)): Use #if and\n\tcall std::distance instead of _S_distance.\n---\n libstdc++-v3/include/bits/stl_list.h | 179 +++++++++++++++------------\n 1 file changed, 97 insertions(+), 82 deletions(-)", "diff": "diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h\nindex 7deb04b4bfe4..d51fde90e2b8 100644\n--- a/libstdc++-v3/include/bits/stl_list.h\n+++ b/libstdc++-v3/include/bits/stl_list.h\n@@ -104,22 +104,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n _M_unhook() _GLIBCXX_USE_NOEXCEPT;\n };\n \n- /// The %list node header.\n- struct _List_node_header : public _List_node_base\n+ struct _List_size\n {\n #if _GLIBCXX_USE_CXX11_ABI\n- std::size_t _M_size;\n+ // Store the size here so that std::list::size() is fast.\n+ size_t _M_size;\n #endif\n+ };\n+\n \n+ /// The %list node header.\n+ struct _List_node_header : public _List_node_base, _List_size\n+ {\n _List_node_header() _GLIBCXX_NOEXCEPT\n { _M_init(); }\n \n #if __cplusplus >= 201103L\n _List_node_header(_List_node_header&& __x) noexcept\n- : _List_node_base{ __x._M_next, __x._M_prev }\n-# if _GLIBCXX_USE_CXX11_ABI\n- , _M_size(__x._M_size)\n-# endif\n+ : _List_node_base(__x), _List_size(__x)\n {\n \tif (__x._M_base()->_M_next == __x._M_base())\n \t this->_M_next = this->_M_prev = this;\n@@ -142,9 +144,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t __node->_M_next = __xnode->_M_next;\n \t __node->_M_prev = __xnode->_M_prev;\n \t __node->_M_next->_M_prev = __node->_M_prev->_M_next = __node;\n-# if _GLIBCXX_USE_CXX11_ABI\n-\t _M_size = __x._M_size;\n-# endif\n+\t _List_size::operator=(__x);\n \t __x._M_init();\n \t }\n }\n@@ -154,9 +154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n _M_init() _GLIBCXX_NOEXCEPT\n {\n \tthis->_M_next = this->_M_prev = this;\n-#if _GLIBCXX_USE_CXX11_ABI\n-\tthis->_M_size = 0;\n-#endif\n+\t_List_size::operator=(_List_size());\n }\n \n private:\n@@ -436,21 +434,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n \trebind<_List_node<_Tp> >::other _Node_alloc_type;\n typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits;\n \n-#if !_GLIBCXX_INLINE_VERSION\n- static size_t\n- _S_distance(const __detail::_List_node_base* __first,\n-\t\t const __detail::_List_node_base* __last)\n- {\n-\tsize_t __n = 0;\n-\twhile (__first != __last)\n-\t {\n-\t __first = __first->_M_next;\n-\t ++__n;\n-\t }\n-\treturn __n;\n- }\n-#endif\n-\n struct _List_impl\n : public _Node_alloc_type\n {\n@@ -488,33 +471,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; }\n \n void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; }\n-\n-# if !_GLIBCXX_INLINE_VERSION\n- size_t\n- _M_distance(const __detail::_List_node_base* __first,\n-\t\t const __detail::_List_node_base* __last) const\n- { return _S_distance(__first, __last); }\n-\n- // return the stored size\n- size_t _M_node_count() const { return _M_get_size(); }\n-# endif\n #else\n // dummy implementations used when the size is not stored\n size_t _M_get_size() const { return 0; }\n void _M_set_size(size_t) { }\n void _M_inc_size(size_t) { }\n void _M_dec_size(size_t) { }\n-\n-# if !_GLIBCXX_INLINE_VERSION\n- size_t _M_distance(const void*, const void*) const { return 0; }\n-\n- // count the number of nodes\n- size_t _M_node_count() const\n- {\n-\treturn _S_distance(_M_impl._M_node._M_next,\n-\t\t\t std::__addressof(_M_impl._M_node));\n- }\n-# endif\n #endif\n \n typename _Node_alloc_traits::pointer\n@@ -549,16 +511,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n #if __cplusplus >= 201103L\n _List_base(_List_base&&) = default;\n \n-# if !_GLIBCXX_INLINE_VERSION\n- _List_base(_List_base&& __x, _Node_alloc_type&& __a)\n- : _M_impl(std::move(__a))\n- {\n-\tif (__x._M_get_Node_allocator() == _M_get_Node_allocator())\n-\t _M_move_nodes(std::move(__x));\n-\t// else caller must move individual elements.\n- }\n-# endif\n-\n // Used when allocator is_always_equal.\n _List_base(_Node_alloc_type&& __a, _List_base&& __x)\n : _M_impl(std::move(__a), std::move(__x._M_impl))\n@@ -584,6 +536,57 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n void\n _M_init() _GLIBCXX_NOEXCEPT\n { this->_M_impl._M_node._M_init(); }\n+\n+#if !_GLIBCXX_INLINE_VERSION\n+ // XXX GLIBCXX_ABI Deprecated\n+ // These members are unused by std::list now, but we keep them here\n+ // so that an explicit instantiation of std::list will define them.\n+ // This ensures that explicit instantiations still define these symbols,\n+ // so that explicit instantiation declarations of std::list that were\n+ // compiled with old versions of GCC can still find these old symbols.\n+\n+# if __cplusplus >= 201103L\n+ _List_base(_List_base&& __x, _Node_alloc_type&& __a)\n+ : _M_impl(std::move(__a))\n+ {\n+\tif (__x._M_get_Node_allocator() == _M_get_Node_allocator())\n+\t _M_move_nodes(std::move(__x));\n+\t// else caller must move individual elements.\n+ }\n+# endif\n+\n+ static size_t\n+ _S_distance(const __detail::_List_node_base* __first,\n+\t\t const __detail::_List_node_base* __last)\n+ {\n+\tsize_t __n = 0;\n+\twhile (__first != __last)\n+\t {\n+\t __first = __first->_M_next;\n+\t ++__n;\n+\t }\n+\treturn __n;\n+ }\n+\n+#if _GLIBCXX_USE_CXX11_ABI\n+ size_t\n+ _M_distance(const __detail::_List_node_base* __first,\n+\t\t const __detail::_List_node_base* __last) const\n+ { return _S_distance(__first, __last); }\n+\n+ // return the stored size\n+ size_t _M_node_count() const { return _M_get_size(); }\n+#else\n+ size_t _M_distance(const void*, const void*) const { return 0; }\n+\n+ // count the number of nodes\n+ size_t _M_node_count() const\n+ {\n+\treturn _S_distance(_M_impl._M_node._M_next,\n+\t\t\t std::__addressof(_M_impl._M_node));\n+ }\n+#endif\n+#endif // ! INLINE_VERSION\n };\n \n /**\n@@ -721,27 +724,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n \t}\n #endif\n \n-#if _GLIBCXX_USE_CXX11_ABI\n- static size_t\n- _S_distance(const_iterator __first, const_iterator __last)\n- { return std::distance(__first, __last); }\n-\n- // return the stored size\n- size_t\n- _M_node_count() const\n- { return this->_M_get_size(); }\n-#else\n- // dummy implementations used when the size is not stored\n- static size_t\n- _S_distance(const_iterator, const_iterator)\n- { return 0; }\n-\n- // count the number of nodes\n- size_t\n- _M_node_count() const\n- { return std::distance(begin(), end()); }\n-#endif\n-\n public:\n // [23.2.2.1] construct/copy/destroy\n // (assign() and get_allocator() are also listed in this section)\n@@ -1193,7 +1175,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n _GLIBCXX_NODISCARD\n size_type\n size() const _GLIBCXX_NOEXCEPT\n- { return _M_node_count(); }\n+ {\n+#if _GLIBCXX_USE_CXX11_ABI\n+\treturn this->_M_get_size(); // return the stored size\n+#else\n+\treturn std::distance(begin(), end()); // count the number of nodes\n+#endif\n+ }\n \n /** Returns the size() of the largest possible %list. */\n _GLIBCXX_NODISCARD\n@@ -1851,9 +1839,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n \t if (this != std::__addressof(__x))\n \t _M_check_equal_allocators(__x);\n \n-\t size_t __n = _S_distance(__first, __last);\n+#if _GLIBCXX_USE_CXX11_ABI\n+\t size_t __n = std::distance(__first, __last);\n \t this->_M_inc_size(__n);\n \t __x._M_dec_size(__n);\n+#endif\n \n \t this->_M_transfer(__position._M_const_cast(),\n \t\t\t __first._M_const_cast(),\n@@ -2213,6 +2203,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11\n { explicit _Finalize_merge(list&, list&, const iterator&) { } };\n #endif\n \n+#if !_GLIBCXX_INLINE_VERSION\n+ // XXX GLIBCXX_ABI Deprecated\n+ // These members are unused by std::list now, but we keep them here\n+ // so that an explicit instantiation of std::list will define them.\n+ // This ensures that any objects or libraries compiled against old\n+ // versions of GCC will still be able to use the symbols.\n+\n+#if _GLIBCXX_USE_CXX11_ABI\n+ static size_t\n+ _S_distance(const_iterator __first, const_iterator __last)\n+ { return std::distance(__first, __last); }\n+\n+ size_t\n+ _M_node_count() const\n+ { return this->_M_get_size(); }\n+#else\n+ static size_t\n+ _S_distance(const_iterator, const_iterator)\n+ { return 0; }\n+\n+ size_t\n+ _M_node_count() const\n+ { return std::distance(begin(), end()); }\n+#endif\n+#endif // ! INLINE_VERSION\n };\n \n #if __cpp_deduction_guides >= 201606\n", "prefixes": [ "v1", "1/4" ] }