Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2226100/?format=api
{ "id": 2226100, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2226100/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.1@forge-stage.sourceware.org/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.2/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.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.1@forge-stage.sourceware.org>", "list_archive_url": null, "date": "2026-04-22T08:54:47", "name": "[v1,1/1] libstdc++: Simplify std::__throw_bad_variant_access", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9436999e9f71a2cc0bfa3af6d4a476657531b526", "submitter": { "id": 93210, "url": "http://patchwork.ozlabs.org/api/1.2/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.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.1@forge-stage.sourceware.org/mbox/", "series": [ { "id": 500949, "url": "http://patchwork.ozlabs.org/api/1.2/series/500949/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500949", "date": "2026-04-22T08:54:46", "name": "libstdc++: Simplify std::__throw_bad_variant_access", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500949/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226100/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226100/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=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; 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\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 4g0tP562Psz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 18:56:09 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 1E9E44B9DB59\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 08:56:07 +0000 (GMT)", "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 99A6F4BA9011\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 08:55:39 +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 7038240526\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 08:55:39 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 1E9E44B9DB59", "OpenDKIM Filter v2.11.0 sourceware.org 99A6F4BA9011" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 99A6F4BA9011", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 99A6F4BA9011", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776848139; cv=none;\n b=TcXorO3EHMEyxHsovX39H7Qu5liztCedpVYmqCbfNK6z7hsSstVYvAIwMGy4HJrSpzKE2ZizGqniEgP6pmBnDI6R+FVJUZihvtr7It9gZsc4LU1cT7VByCFP+Fth2iz3OuIgsCgAPf5TBpl41YEL6EaofHGgPSjwktA4TnXNWlc=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776848139; c=relaxed/simple;\n bh=XBjzGOByJzxsR6xBpURWu4tKluqejhMUXPi3YCY4LSw=;\n h=From:Date:Subject:To:Message-ID;\n b=Uc2UdVgceiJS8sXfRxXkNICoI/Aumc+mCQWIz4bgNssCCjZ1VGzfQzEW5ClbkeBI4EQPhhhHZq+JmTWtarczd8Z0K+PzEFkjejMTxxFi8lBpdS/dRkyuol688izJNC7VZwWzpQzzflRjb5A23hWFy0eOSjjKGs3jW5i2MxoHEAE=", "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 08:54:47 +0000", "Subject": "[PATCH v1 1/1] libstdc++: Simplify std::__throw_bad_variant_access", "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>", "Message-ID": "\n <bmm.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.1@forge-stage.sourceware.org>", "X-Mailer": "batrachomyomachia", "X-Requested-Reviewer": "ppalka", "X-Pull-Request-Organization": "gcc", "X-Pull-Request-Repository": "gcc-TEST", "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/3", "References": "\n <bmm.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.0@forge-stage.sourceware.org>", "In-Reply-To": "\n <bmm.hhu8qqul0c.gcc.gcc-TEST.redi.3.1.0@forge-stage.sourceware.org>", "X-Patch-URL": "\n https://forge.sourceware.org/redi/gcc/commit/f9cdc7e69f3aa30fb19aec0ee30d31bb43601515", "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\nThis removes the overload of __throw_bad_variant_access that must be\ncalled with a string literal. This avoids a potential source of\nundefined behaviour if that function got misused. The other overload\nthat takes a bool parameter can be adjusted to take an integer index\nselecting one of the four possible string literals to use, ensuring\nthat the std::bad_variant_access constructor is only called with those\nliterals.\n\nPassing an index outside the range [0,3] is bogus, but will still select\na valid string literal and avoid undefined behaviour.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/std/variant (__throw_bad_variant_access(unsigned)):\n\tDefine new function as inline friend, with namespace-scope\n\tdeclaration using noreturn attribute.\n\t(__throw_bad_variant_access(const char*)): Remove.\n\t(__throw_bad_variant_access(bool)): Remove.\n\t(visit, visit<R>): Adjust calls to __throw_bad_variant_access.\n---\n libstdc++-v3/include/std/variant | 32 +++++++++++++++-----------------\n 1 file changed, 15 insertions(+), 17 deletions(-)", "diff": "diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant\nindex cf532126d798..6d768e10bf95 100644\n--- a/libstdc++-v3/include/std/variant\n+++ b/libstdc++-v3/include/std/variant\n@@ -1402,6 +1402,8 @@ namespace __detail::__variant\n \t\t && (is_swappable_v<_Types> && ...))>\n swap(variant<_Types...>&, variant<_Types...>&) = delete;\n \n+ [[noreturn]] void __throw_bad_variant_access(unsigned);\n+\n class bad_variant_access : public exception\n {\n public:\n@@ -1411,28 +1413,24 @@ namespace __detail::__variant\n { return _M_reason; }\n \n private:\n+ // Must only be called with a string literal\n bad_variant_access(const char* __reason) noexcept : _M_reason(__reason) { }\n \n // Must point to a string with static storage duration:\n const char* _M_reason = \"bad variant access\";\n \n- friend void __throw_bad_variant_access(const char* __what);\n+ friend void __throw_bad_variant_access(unsigned __n)\n+ {\n+ [[maybe_unused]] static constexpr const char* __reasons[] = {\n+\t\"std::get: wrong index for variant\",\n+\t\"std::get: variant is valueless\",\n+\t\"std::visit: variant is valueless\",\n+\t\"std::visit<R>: variant is valueless\",\n+ };\n+ _GLIBCXX_THROW_OR_ABORT(bad_variant_access(__reasons[__n % 4u]));\n+ }\n };\n \n- // Must only be called with a string literal\n- inline void\n- __throw_bad_variant_access(const char* __what)\n- { _GLIBCXX_THROW_OR_ABORT(bad_variant_access(__what)); }\n-\n- inline void\n- __throw_bad_variant_access(bool __valueless)\n- {\n- if (__valueless) [[__unlikely__]]\n- __throw_bad_variant_access(\"std::get: variant is valueless\");\n- else\n- __throw_bad_variant_access(\"std::get: wrong index for variant\");\n- }\n-\n template<typename... _Types>\n class variant\n : private __detail::__variant::_Variant_base<_Types...>,\n@@ -1941,7 +1939,7 @@ namespace __detail::__variant\n namespace __variant = std::__detail::__variant;\n \n if ((__variant::__as(__variants).valueless_by_exception() || ...))\n-\t__throw_bad_variant_access(\"std::visit: variant is valueless\");\n+\t__throw_bad_variant_access(2);\n \n using _Result_type\n \t= __detail::__variant::__visit_result_t<_Visitor, _Variants...>;\n@@ -1981,7 +1979,7 @@ namespace __detail::__variant\n namespace __variant = std::__detail::__variant;\n \n if ((__variant::__as(__variants).valueless_by_exception() || ...))\n-\t__throw_bad_variant_access(\"std::visit<R>: variant is valueless\");\n+\t__throw_bad_variant_access(3);\n \n return std::__do_visit<_Res>(std::forward<_Visitor>(__visitor),\n \t __variant::__as(std::forward<_Variants>(__variants))...);\n", "prefixes": [ "v1", "1/1" ] }