get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2226723/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2226723,
    "url": "http://patchwork.ozlabs.org/api/patches/2226723/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.8@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.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.8@forge-stage.sourceware.org>",
    "list_archive_url": null,
    "date": "2026-04-22T18:27:32",
    "name": "[v1,8/8] libstdc++: Directly implement ranges::shuffle [PR100795]",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "66709b688e66e64124fff423aab9ea0808ff603e",
    "submitter": {
        "id": 93215,
        "url": "http://patchwork.ozlabs.org/api/people/93215/?format=api",
        "name": "ppalka via Sourceware Forge",
        "email": "forge-bot+ppalka@forge-stage.sourceware.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.8@forge-stage.sourceware.org/mbox/",
    "series": [
        {
            "id": 501079,
            "url": "http://patchwork.ozlabs.org/api/series/501079/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501079",
            "date": "2026-04-22T18:27:24",
            "name": "libstdc++: C++20 iterator awareness fixes for various Ranges algorithms [PR100795]",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/501079/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2226723/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2226723/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 4g17dw5B7gz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 04:53:08 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DDFE140A2C74\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 18:53:06 +0000 (GMT)",
            "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 8C96748FED96\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:28:37 +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 57E07434A3\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:28:35 +0000 (UTC)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org DDFE140A2C74",
            "OpenDKIM Filter v2.11.0 sourceware.org 8C96748FED96"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 8C96748FED96",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 8C96748FED96",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776882517; cv=none;\n b=d5YBhsaBwkZuqYUXS5kxPzddD+gcCKwxTsKth3NtzukokC5ZB6Op93YMWiVBfcqcO8qDi8cnzCma4qT7/ljQB/HBceJ6cr1xhgUCk/e471PCJhv+XeBdBLVltfMYqJ1nhyfTkPxK8tptiwCK6RrA7KMRWPElNCk7Fy/yQ8J/J5k=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776882517; c=relaxed/simple;\n bh=tsU7zPesNWpEEqdIF/bcPclx4XA1cLwPbnPXKfdP9O0=;\n h=From:Date:Subject:To:Message-ID;\n b=g3MmUNTWRDqJQrAQk3IEXoCLybT0/fDr9RjRf2dIgP1XLB4uUCyvVnuOWPJgtAShLWygphmrQyE9xNva40kKvBzk+7GAY0ACN8BFwHELvdzEfkT9J7xxM9s6ANJ7csVWMBNFn5fYthvmrKLiRBydXdyJGexCwBul//X0DL4AIKs=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "From": "ppalka via Sourceware Forge\n <forge-bot+ppalka@forge-stage.sourceware.org>",
        "Date": "Wed, 22 Apr 2026 18:27:32 +0000",
        "Subject": "[PATCH v1 8/8] libstdc++: Directly implement ranges::shuffle\n [PR100795]",
        "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>",
        "Message-ID": "\n <bmm.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.8@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/57",
        "References": "\n <bmm.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.0@forge-stage.sourceware.org>",
        "In-Reply-To": "\n <bmm.hhuoj2uk6c.gcc.gcc-TEST.ppalka.57.1.0@forge-stage.sourceware.org>",
        "X-Patch-URL": "\n https://forge.sourceware.org/gcc/gcc-TEST/commit/a3c5a8afc73bbf2a4e4ae14cb51119c92fc1340d",
        "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 ppalka@gcc.gnu.org",
        "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"
    },
    "content": "From: Patrick Palka <ppalka@redhat.com>\n\n\tPR libstdc++/100795\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/ranges_algo.h (shuffle_fn::operator()):\n\tReimplement directly.\n\t* testsuite/25_algorithms/shuffle/constrained.cc (test02):\n---\n libstdc++-v3/include/bits/ranges_algo.h       | 58 ++++++++++++++++++-\n .../25_algorithms/shuffle/constrained.cc      | 25 ++++++++\n 2 files changed, 80 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h\nindex 672a0ebce0de..83eaa7da28b9 100644\n--- a/libstdc++-v3/include/bits/ranges_algo.h\n+++ b/libstdc++-v3/include/bits/ranges_algo.h\n@@ -1952,9 +1952,61 @@ namespace ranges\n       _Iter\n       operator()(_Iter __first, _Sent __last, _Gen&& __g) const\n       {\n-\tauto __lasti = ranges::next(__first, __last);\n-\tstd::shuffle(std::move(__first), __lasti, std::forward<_Gen>(__g));\n-\treturn __lasti;\n+\t// FIXME: Correctly handle integer-class difference types.\n+\tif (__first == __last)\n+\t  return __first;\n+\n+\tusing _DistanceType = iter_difference_t<_Iter>;\n+\tusing __ud_type = __detail::__make_unsigned_like_t<_DistanceType>;\n+\tusing __distr_type = std::uniform_int_distribution<__ud_type>;\n+\tusing __p_type = typename __distr_type::param_type;\n+\n+\tusing __uc_type\n+\t  = common_type_t<typename remove_reference_t<_Gen>::result_type, __ud_type>;\n+\n+\tconst __uc_type __urngrange = __g.max() - __g.min();\n+\tconst __uc_type __urange = __uc_type(__last - __first);\n+\n+\tif (__urngrange / __urange >= __urange)\n+\t  // I.e. (__urngrange >= __urange * __urange) but without wrap issues.\n+\t  {\n+\t    _Iter __i = __first + 1;\n+\n+\t    // Since we know the range isn't empty, an even number of elements\n+\t    // means an uneven number of elements /to swap/, in which case we\n+\t    // do the first one up front:\n+\n+\t    if ((__urange % 2) == 0)\n+\t      {\n+\t\t__distr_type __d{0, 1};\n+\t\tranges::iter_swap(__i++, __first + __d(__g));\n+\t      }\n+\n+\t    // Now we know that __last - __i is even, so we do the rest in pairs,\n+\t    // using a single distribution invocation to produce swap positions\n+\t    // for two successive elements at a time:\n+\n+\t    while (__i != __last)\n+\t      {\n+\t\tconst __uc_type __swap_range = __uc_type(__i - __first) + 1;\n+\n+\t\tconst pair<__uc_type, __uc_type> __pospos =\n+\t\t  __gen_two_uniform_ints(__swap_range, __swap_range + 1, __g);\n+\n+\t\tranges::iter_swap(__i++, __first + __pospos.first);\n+\t\tranges::iter_swap(__i++, __first + __pospos.second);\n+\t      }\n+\n+\t    return __i;\n+\t  }\n+\n+\t__distr_type __d;\n+\n+\t_Iter __i = __first + 1;\n+\tfor (; __i != __last; ++__i)\n+\t  ranges::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first)));\n+\n+\treturn __i;\n       }\n \n     template<random_access_range _Range, typename _Gen>\ndiff --git a/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc\nindex d0977a292fee..70c6bdfc3d9e 100644\n--- a/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc\n+++ b/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc\n@@ -20,6 +20,7 @@\n \n #include <algorithm>\n #include <random>\n+#include <ranges>\n #include <vector>\n #include <testsuite_hooks.h>\n #include <testsuite_iterators.h>\n@@ -62,8 +63,32 @@ test01()\n     }\n }\n \n+void\n+test02()\n+{\n+  // PR libstdc++/100795 - ranges::shuffle should not use std::shuffle directly\n+#if 0 // FIXME: ranges::shuffle rejects integer-class difference types.\n+#if __SIZEOF_INT128__\n+  auto v = std::views::iota(__int128(0), __int128(20));\n+#else\n+  auto v = std::views::iota(0ll, 20ll);\n+#endif\n+#else\n+  auto v = std::views::iota(0, 20);\n+#endif\n+\n+  int storage[20] = {2,5,4,3,1,6,7,9,10,8,11,14,12,13,15,16,18,0,19,17};\n+  auto w = v | std::views::transform([&](auto i) -> int& { return storage[i]; });\n+  using type = decltype(w);\n+  static_assert( std::ranges::random_access_range<type> );\n+\n+  std::ranlux48_base g;\n+  ranges::shuffle(w, g);\n+}\n+\n int\n main()\n {\n   test01();\n+  test02();\n }\n",
    "prefixes": [
        "v1",
        "8/8"
    ]
}