Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2222777/?format=api
{ "id": 2222777, "url": "http://patchwork.ozlabs.org/api/patches/2222777/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260413164814.90675-1-jwakely@redhat.com/", "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": "<20260413164814.90675-1-jwakely@redhat.com>", "list_archive_url": null, "date": "2026-04-13T16:47:58", "name": "c++tools: Use std::map::try_emplace to avoid use-after-move", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "fdb812622edca4ab30f9f407f5c23aec660f65f0", "submitter": { "id": 48004, "url": "http://patchwork.ozlabs.org/api/people/48004/?format=api", "name": "Jonathan Wakely", "email": "jwakely@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260413164814.90675-1-jwakely@redhat.com/mbox/", "series": [ { "id": 499729, "url": "http://patchwork.ozlabs.org/api/series/499729/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499729", "date": "2026-04-13T16:47:58", "name": "c++tools: Use std::map::try_emplace to avoid use-after-move", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499729/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222777/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222777/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\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=YaPN/VRN;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::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;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=YaPN/VRN", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com", "sourceware.org; spf=pass smtp.mailfrom=redhat.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::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 4fvYJg0Srvz1yDG\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 02:48:51 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 133FD4BA2E25\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 16:48:49 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 9C23A4BA2E1E\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 16:48:22 +0000 (GMT)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-lhJrkKiqOQuIKIgs0BgCNQ-1; Mon,\n 13 Apr 2026 12:48:17 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id DB0151800454\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 16:48:16 +0000 (UTC)", "from zen.kayari.org (unknown [10.44.34.88])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id DCECC180049F\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 16:48:15 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 133FD4BA2E25", "OpenDKIM Filter v2.11.0 sourceware.org 9C23A4BA2E1E" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 9C23A4BA2E1E", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 9C23A4BA2E1E", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776098902; cv=none;\n b=P5GxNKaIuq6c78IPXVICIpCQRy4vVJU6rtQa16blFDeEXmDMrHSomzp1IgRcTAZvgzHS4Ug+IGsjDO/zdvryJbUW1Qs8NXY2Pgh9y/znYSIyerAZi4GdG/srq87fac8iBWFQJ4YGuL5iJTeyTt/z4EXiJqa2nasd2erag3Vmwak=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776098902; c=relaxed/simple;\n bh=P5wTEkhnHP/t7br5cPBpS/eHznq1AkDMkU/ihdZOzQc=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=mba9MRG5jrHe+niI+PF0OROKsfZ8N7FG6bctMDCw9JxqUJa3sNGBO3/jZ1saOHznXu9J25epDB8CFW+OfppqwVpyAA4oEx56baHULiF4gSTgpuxUc44IGuwgAQwz4hdfSFEMyyUhUb4vsY/aS/n+3kDzED4cYGpJUJ5MveQeFvo=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776098902;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=VXjWulI69pcAg2iY1PuG15K9kNHMBEqsX9Y829tB4tI=;\n b=YaPN/VRNeUh966D2xinuNPF280PbendPpSV5eyheo9y6TGkIyf3WzR5xHaB4TGJavAeCri\n c74blYZKu1zVfG7ehMr4Nsd3DJyQj9uXAX2pWbPTpq2XayqtNVWPQPdeM4Ovj4f7pV7pNF\n B1MHfVwCfWusZwtQt9c5b338ZVOULvQ=", "X-MC-Unique": "lhJrkKiqOQuIKIgs0BgCNQ-1", "X-Mimecast-MFC-AGG-ID": "lhJrkKiqOQuIKIgs0BgCNQ_1776098897", "From": "Jonathan Wakely <jwakely@redhat.com>", "To": "gcc-patches@gcc.gnu.org", "Subject": "[PATCH] c++tools: Use std::map::try_emplace to avoid use-after-move", "Date": "Mon, 13 Apr 2026 17:47:58 +0100", "Message-ID": "<20260413164814.90675-1-jwakely@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "WAK4uIr0LthSjLiE8MMpncM-BzTsszv_rjA7qcpr8vE_1776098897", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "With std::map in libstdc++, std::map::emplace always forwards its\nparameters and constructs a node from them. This means that the file\nparameter will have been moved-from and so might be empty when it is\nused again in the assignment.\n\nUse the C++17 try_emplace member (supported since GCC 6.1.0), which\nguarantees to have no effects on the parameters if no insertion happens.\nFor C++14 and GCC 5.x, pass the file parameter to emplace as an lvalue\nso it isn't moved.\n\nc++tools/ChangeLog:\n\n\t* resolver.cc (module_resolver::add_mapping): Use try_emplace\n\twhen available and avoid use-after-move otherwise.\n---\n c++tools/resolver.cc | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)", "diff": "diff --git a/c++tools/resolver.cc b/c++tools/resolver.cc\nindex 53c48b4fc6a8..f4d8029b43af 100644\n--- a/c++tools/resolver.cc\n+++ b/c++tools/resolver.cc\n@@ -88,9 +88,13 @@ module_resolver::set_repo (std::string &&r, bool force)\n bool\n module_resolver::add_mapping (std::string &&module, std::string &&file,\n \t\t\t bool force)\n {\n- auto res = map.emplace (std::move (module), std::move (file));\n+#ifdef __cpp_lib_map_try_emplace\n+ auto res = map.try_emplace (std::move (module), std::move (file));\n+#else\n+ auto res = map.emplace (std::move (module), file);\n+#endif\n if (res.second)\n force = true;\n else if (force)\n res.first->second = std::move (file);\n", "prefixes": [] }