Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2226644/?format=api
{ "id": 2226644, "url": "http://patchwork.ozlabs.org/api/patches/2226644/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhundg5lhq.gcc.gcc-TEST.peppe.35.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.hhundg5lhq.gcc.gcc-TEST.peppe.35.1.1@forge-stage.sourceware.org>", "list_archive_url": null, "date": "2026-04-22T17:45:34", "name": "[v1,1/1] libstdc++: fix compile error when converting std::weak_ptr<T[]>", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "fa29a5a7d9767d2c0f78aac7d8a6626b748237fc", "submitter": { "id": 93222, "url": "http://patchwork.ozlabs.org/api/people/93222/?format=api", "name": "peppe via Sourceware Forge", "email": "forge-bot+peppe@forge-stage.sourceware.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhundg5lhq.gcc.gcc-TEST.peppe.35.1.1@forge-stage.sourceware.org/mbox/", "series": [ { "id": 501055, "url": "http://patchwork.ozlabs.org/api/series/501055/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501055", "date": "2026-04-22T17:45:34", "name": "WIP: libstdc++: fix compile error when converting std::weak_ptr<T[]>", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501055/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226644/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226644/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 4g169S55NZz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 03:46:52 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DE79E4BB5889\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 17:46:50 +0000 (GMT)", "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id B582F4BAD163\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 17:46:24 +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 876F942BEB\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 17:46:24 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org DE79E4BB5889", "OpenDKIM Filter v2.11.0 sourceware.org B582F4BAD163" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org B582F4BAD163", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org B582F4BAD163", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776879984; cv=none;\n b=h3vTOT9wVCUs0NwAbg5bh+Pl+Mki/DRoDeosFUtxZJSLwbbrukiLPMlSxa5GvAT8ZGz+gzx6zd1hZLqEtmBNOdkI6VRstxJh0Cqn+OSCMGrL/5EJBefNfx7STnxQGckW95vNHIADmMABsFjNeQaDVMkIPYZ3XtafhY0j0qC5RAM=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776879984; c=relaxed/simple;\n bh=E6pGoksu3+AKilIStwQzR/oeWUs+nkpg45+/T+a2LEM=;\n h=From:Date:Subject:To:Message-ID;\n b=uMaWfEeucMt9dGOnpFP8gBw9GTjQC2UtdnTKYU8CWkAA3qUeHf4D8WoZ1ynEJceKzfgOE1Qa1l/KNvd8NkGcmZBRWQ4QqD0pkWi1GLf/au9P5BzpBJG4OjPOvZ5tcUd2OveYZ/AFolUvYM+PAr1Clb6ao3pN/5OwF+Ohbzi2twE=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "peppe via Sourceware Forge <forge-bot+peppe@forge-stage.sourceware.org>", "Date": "Wed, 22 Apr 2026 17:45:34 +0000", "Subject": "[PATCH v1 1/1] libstdc++: fix compile error when converting\n std::weak_ptr<T[]>", "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>", "Message-ID": "\n <bmm.hhundg5lhq.gcc.gcc-TEST.peppe.35.1.1@forge-stage.sourceware.org>", "X-Mailer": "batrachomyomachia", "X-Requested-Reviewer": "redi", "X-Pull-Request-Organization": "gcc", "X-Pull-Request-Repository": "gcc-TEST", "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/35", "References": "\n <bmm.hhundg5lhq.gcc.gcc-TEST.peppe.35.1.0@forge-stage.sourceware.org>", "In-Reply-To": "\n <bmm.hhundg5lhq.gcc.gcc-TEST.peppe.35.1.0@forge-stage.sourceware.org>", "X-Patch-URL": "\n https://forge.sourceware.org/peppe/gcc-TEST/commit/5f1498adeac4466e9edf60fdc708d8fed0d6b7ab", "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>,\n peppe@noreply.localhost", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>\n\nA std::weak_ptr<T[]> can be converted to a compatible\nstd::weak_ptr<U[]>. This is implemented by having suitable converting\nconstructors to std::weak_ptr which dispatch to the __weak_ptr base\nclass (implementation detail).\n\nIn __weak_ptr<T[]>, lock() is supposed to return a __shared_ptr<T[]>,\nnot a __shared_ptr<element_type> (that is, __shared_ptr<T>).\n\nUnfortunately the return type of lock() and the type of the returned\n__shared_ptr were mismatching and that was causing a compile error: when\nconverting a __weak_ptr<T[]> to a __weak_ptr<U[]> through __weak_ptr's\nconverting constructor, the code calls lock(), and that simply fails to\nbuild.\n\nFix it by removing the usage of element_type inside lock(), and using\n_Tp instead.\n\nNote that std::weak_ptr::lock() itself was already correct; the one in\n__weak_ptr was faulty (and that is the one called by __weak_ptr's\nconverting constructors).\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/shared_ptr_base.h (lock): Fixed a compile error\n\twhen calling lock() on a weak_ptr<T[]>, by removing an\n\terroneous usage of element_type from within lock().\n\t* testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc:\n\tAdd more tests for array types.\n\t* testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc:\n\tLikewise.\n\t* testsuite/20_util/shared_ptr/requirements/1.cc: New test.\n\t* testsuite/20_util/weak_ptr/requirements/1.cc: New test.\n---\n libstdc++-v3/include/bits/shared_ptr_base.h | 2 +-\n .../20_util/shared_ptr/requirements/1.cc | 33 +++++++++++++++++++\n .../requirements/explicit_instantiation/1.cc | 12 +++++++\n .../20_util/weak_ptr/requirements/1.cc | 33 +++++++++++++++++++\n .../requirements/explicit_instantiation/1.cc | 12 +++++++\n 5 files changed, 91 insertions(+), 1 deletion(-)\n create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc\n create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc", "diff": "diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h\nindex 053857b4c29f..3622e0291178 100644\n--- a/libstdc++-v3/include/bits/shared_ptr_base.h\n+++ b/libstdc++-v3/include/bits/shared_ptr_base.h\n@@ -2075,7 +2075,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \n __shared_ptr<_Tp, _Lp>\n lock() const noexcept\n- { return __shared_ptr<element_type, _Lp>(*this, std::nothrow); }\n+ { return __shared_ptr<_Tp, _Lp>(*this, std::nothrow); }\n \n long\n use_count() const noexcept\ndiff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc\nnew file mode 100644\nindex 000000000000..8ddb5d220ac7\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc\n@@ -0,0 +1,33 @@\n+// { dg-do compile { target c++11 } }\n+// { dg-require-effective-target hosted }\n+\n+#include <memory>\n+#include <testsuite_tr1.h>\n+\n+using namespace __gnu_test;\n+\n+void\n+test01()\n+{\n+ std::shared_ptr<ClassType> ptr;\n+ std::shared_ptr<const ClassType> ptr2 = ptr;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+ std::shared_ptr<ClassType[10]> ptr_array;\n+ std::shared_ptr<ClassType[]> ptr_array2 = ptr_array;\n+ std::shared_ptr<ClassType const []> ptr_array3 = ptr_array;\n+#endif\n+}\n+\n+void\n+test02()\n+{\n+ std::shared_ptr<IncompleteClass> ptr;\n+ std::shared_ptr<const IncompleteClass> ptr2 = ptr;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+ std::shared_ptr<IncompleteClass[10]> ptr_array;\n+ std::shared_ptr<IncompleteClass[]> ptr_array2 = ptr_array;\n+ std::shared_ptr<IncompleteClass const []> ptr_array3 = ptr_array;\n+#endif\n+}\ndiff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc\nindex 6418e0c4bc7c..3bd05c36f8fc 100644\n--- a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc\n+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc\n@@ -28,3 +28,15 @@ template class std::shared_ptr<int>;\n template class std::shared_ptr<void>;\n template class std::shared_ptr<ClassType>;\n template class std::shared_ptr<IncompleteClass>;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+template class std::shared_ptr<ClassType []>;\n+template class std::shared_ptr<ClassType [42]>;\n+template class std::shared_ptr<ClassType const []>;\n+template class std::shared_ptr<ClassType const [42]>;\n+\n+template class std::shared_ptr<IncompleteClass []>;\n+template class std::shared_ptr<IncompleteClass [42]>;\n+template class std::shared_ptr<IncompleteClass const []>;\n+template class std::shared_ptr<IncompleteClass const [42]>;\n+#endif\ndiff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc\nnew file mode 100644\nindex 000000000000..04ea837d85a7\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc\n@@ -0,0 +1,33 @@\n+// { dg-do compile { target c++11 } }\n+// { dg-require-effective-target hosted }\n+\n+#include <memory>\n+#include <testsuite_tr1.h>\n+\n+using namespace __gnu_test;\n+\n+void\n+test01()\n+{\n+ std::weak_ptr<ClassType> ptr;\n+ std::weak_ptr<const ClassType> ptr2 = ptr;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+ std::weak_ptr<ClassType[10]> ptr_array;\n+ std::weak_ptr<ClassType[]> ptr_array2 = ptr_array;\n+ std::weak_ptr<ClassType const []> ptr_array3 = ptr_array;\n+#endif\n+}\n+\n+void\n+test02()\n+{\n+ std::weak_ptr<IncompleteClass> ptr;\n+ std::weak_ptr<const IncompleteClass> ptr2 = ptr;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+ std::weak_ptr<IncompleteClass[10]> ptr_array;\n+ std::weak_ptr<IncompleteClass[]> ptr_array2 = ptr_array;\n+ std::weak_ptr<IncompleteClass const []> ptr_array3 = ptr_array;\n+#endif\n+}\ndiff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc\nindex b2704d659db4..24d16ef0e566 100644\n--- a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc\n+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc\n@@ -28,3 +28,15 @@ template class std::weak_ptr<int>;\n template class std::weak_ptr<void>;\n template class std::weak_ptr<ClassType>;\n template class std::weak_ptr<IncompleteClass>;\n+\n+#if __cpp_lib_shared_ptr_arrays >= 201611L\n+template class std::weak_ptr<ClassType []>;\n+template class std::weak_ptr<ClassType [42]>;\n+template class std::weak_ptr<ClassType const []>;\n+template class std::weak_ptr<ClassType const [42]>;\n+\n+template class std::weak_ptr<IncompleteClass []>;\n+template class std::weak_ptr<IncompleteClass [42]>;\n+template class std::weak_ptr<IncompleteClass const []>;\n+template class std::weak_ptr<IncompleteClass const [42]>;\n+#endif\n", "prefixes": [ "v1", "1/1" ] }