Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2227723/?format=api
{ "id": 2227723, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2227723/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260424065244.262557-4-tkaminsk@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/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 }, "msgid": "<20260424065244.262557-4-tkaminsk@redhat.com>", "date": "2026-04-24T06:41:11", "name": "[v2,4/4] libstdc++: Make ref_view<R> statically sized if R has static size", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "acfbe9adec051e86d70fbdfc62eec9b80ec1cfc5", "submitter": { "id": 90409, "url": "http://patchwork.ozlabs.org/api/1.1/people/90409/?format=api", "name": "Tomasz Kamiński", "email": "tkaminsk@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260424065244.262557-4-tkaminsk@redhat.com/mbox/", "series": [ { "id": 501310, "url": "http://patchwork.ozlabs.org/api/1.1/series/501310/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501310", "date": "2026-04-24T06:41:08", "name": "[v2,1/4] libstdc++: Merged concept for ranges with static sized.", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/501310/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2227723/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2227723/checks/", "tags": {}, "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=JbvxjP5G;\n\tdkim-atps=neutral", "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;\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=JbvxjP5G", "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 [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 4g23fm0CxNz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 16:57:04 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 0F4A04BB24D5\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 06:57:02 +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 7375B4BB24D8\n for <gcc-patches@gcc.gnu.org>; Fri, 24 Apr 2026 06:52:58 +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-330-qwp3OcPbNI-61MWrsYSqnA-1; Fri,\n 24 Apr 2026 02:52:54 -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 24C7618005B1; Fri, 24 Apr 2026 06:52:53 +0000 (UTC)", "from localhost (unknown [10.44.48.150])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id A27DE180047F; Fri, 24 Apr 2026 06:52:52 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 0F4A04BB24D5", "OpenDKIM Filter v2.11.0 sourceware.org 7375B4BB24D8" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 7375B4BB24D8", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 7375B4BB24D8", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777013578; cv=none;\n b=NYEhOSReO90MbwNRAm61xJE60QhdgLxSCHMeKFm+k6gT9pVRT2GYzHsxOQ7yAxrxC4zJ2h14JAfMjwCQPjuGyzIt9yd72m+IleQr4Ix7P8wUiC5RT8iKBkPHDfsXVaMrk3bzbT4b9vX7WN0fbdX2/cfhsSn3Wy96HVGOXA3LA8o=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777013578; c=relaxed/simple;\n bh=iSowgv4XpGN4k3OWOkjgV0sF9sy8375QxolopR3UeC0=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=ckIgQow7pxDvksabTsbXBukSTbkMPJUEjgvs14shfSNMjdexu1UfpzvGnxGo9C9sTtAA89NdB+0umJU8lTkH/+sLV1Srgxyxot7VredIhLJkrSiaMalp2ycfV4OIIhoERlWlp2tQbLFui3Gwng5RFmJVpjgjOAhIsbV/gTe/MIU=", "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=1777013578;\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 in-reply-to:in-reply-to:references:references;\n bh=tHCYqDlfAHN0yv50/ZQ7chlIWxFN/5QDfQFLFcadQgg=;\n b=JbvxjP5GjFkd3UfsGh2nmmCtcPDhjAo+p9Wox2WTDzPiRh1NwBOwQnzAI/KtIHAJM9byik\n pxcFgrD94t0ypxGAZCZ8zT6MlUMvSQiQVZ/xZ2Vv3soxMWvQIJqN34F3tZmkX86UPCN9qN\n GdcxCn70sEp39p+jNfuBeS636q4Wd5k=", "X-MC-Unique": "qwp3OcPbNI-61MWrsYSqnA-1", "X-Mimecast-MFC-AGG-ID": "qwp3OcPbNI-61MWrsYSqnA_1777013573", "From": "=?utf-8?q?Tomasz_Kami=C5=84ski?= <tkaminsk@redhat.com>", "To": "libstdc++@gcc.gnu.org,\n\tgcc-patches@gcc.gnu.org", "Subject": "[PATCH v2 4/4] libstdc++: Make ref_view<R> statically sized if R has\n static size", "Date": "Fri, 24 Apr 2026 08:41:11 +0200", "Message-ID": "<20260424065244.262557-4-tkaminsk@redhat.com>", "In-Reply-To": "<20260424065244.262557-1-tkaminsk@redhat.com>", "References": "\n <CAKvuMXD7w0Psg1NYzgPYvqPg6WdgzSd0_NaU=8-yD6sVzhpGQQ@mail.gmail.com>\n <20260424065244.262557-1-tkaminsk@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": "U5QePfIOrCAQMJeZdQK75alaDsGKwW8A_Jta5wzf9hs_1777013573", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "This patch introduces ranges::__static_size<_Range> helper functions,\nthat returns ranges::size(__rg) for __statically_sized_range.\nThis function is then used for ref_view<R>::size if R has static size,\navoiding derefence of pointer value that is not know at compile time.\nSimilary for ref_view<R>::empty() we compare the size with zero,\nif it is know statically.\n\nThis implements revelant part of P3928R0: static_sized_range by Hewill Kang.\nAs standard does not specify when constexpr functions are usable at compile\ntime, such implementation are allowed (but not mandated) by current draft.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/ranges_base.h (ranges::__static_size): Define.\n\t* include/std/ranges (ref_view::size()): For ranges with static\n\tsize return ranges::__static_size<_Range> == 0.\n\t(ref_view::empty): For ranges with static size, compare it\n\tagainst zero.\n\t* testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc:\n\tExpect errors from ref_view uses.\n\t* testsuite/23_containers/inplace_vector/cons/from_range_neg.cc:\n\tExpect errors from ref_view uses.\n---\nv2 also expands the empty() method, and adds __static_size helper funciton.\nWe could really use some consteval __builtin_unknown_ref(_Tp), that will\nproduce reference to unknown object of type _Tp. This will avoid nested\nlambda and instantiating integer_constant.\n\nTested on x86_64-linux. OK for trunk?\n\n libstdc++-v3/include/bits/ranges_base.h | 9 +++++++++\n libstdc++-v3/include/std/ranges | 18 ++++++++++++++++--\n .../inplace_vector/cons/from_iota_neg.cc | 6 ++----\n .../inplace_vector/cons/from_range_neg.cc | 10 ++++------\n 4 files changed, 31 insertions(+), 12 deletions(-)", "diff": "diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h\nindex fea4100eb09..e61ef75f857 100644\n--- a/libstdc++-v3/include/bits/ranges_base.h\n+++ b/libstdc++-v3/include/bits/ranges_base.h\n@@ -562,6 +562,15 @@ namespace ranges\n template<typename _Tp>\n concept __static_sized_range = sized_range<_Tp> && requires (_Tp& __t)\n { static_cast<char(*)[size_t(ranges::size(__t) >= 0)]>(nullptr); };\n+\n+ template<__static_sized_range _Tp>\n+ consteval range_size_t<_Tp>\n+ __static_size()\n+ {\n+ auto __conjure = [](_Tp& __t)\n+ { return integral_constant<range_size_t<_Tp>, ranges::size(__t)>{}; };\n+ return decltype(__conjure(std::declval<_Tp&>()))::value;\n+ }\n #endif // C++26\n \n template<typename _Derived>\ndiff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges\nindex 4f2082487d1..c1e8ac3cb17 100644\n--- a/libstdc++-v3/include/std/ranges\n+++ b/libstdc++-v3/include/std/ranges\n@@ -1380,11 +1380,25 @@ namespace views::__adaptor\n \n constexpr bool\n empty() const requires requires { ranges::empty(*_M_r); }\n- { return ranges::empty(*_M_r); }\n+ {\n+#if __cplusplus > 202302L\n+\tif constexpr (__static_sized_range<_Range>)\n+\t return ranges::__static_size<_Range>() == 0;\n+ else\n+#endif\n+\t return ranges::empty(*_M_r);\n+ }\n \n constexpr auto\n size() const requires sized_range<_Range>\n- { return ranges::size(*_M_r); }\n+ {\n+#if __cplusplus > 202302L\n+\tif constexpr (__static_sized_range<_Range>)\n+\t return ranges::__static_size<_Range>();\n+ else\n+#endif\n+\t return ranges::size(*_M_r);\n+ }\n \n constexpr auto\n data() const requires contiguous_range<_Range>\ndiff --git a/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc b/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc\nindex ae0b96175b7..6b66b5d97ed 100644\n--- a/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc\n+++ b/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_iota_neg.cc\n@@ -33,14 +33,12 @@ test_all()\n std::inplace_vector<int, 15> tr1(std::from_range, ref_view(m12));\n \n std::inplace_vector<int, 10> tm2(std::from_range, m12); // { dg-error \"(from here|expansion of)\" }\n- // ref_view is not statically sized due pointer dereference\n- std::inplace_vector<int, 10> tr2(std::from_range, ref_view(m12));\n+ std::inplace_vector<int, 10> tr2(std::from_range, ref_view(m12)); // { dg-error \"(from here|expansion of)\" }\n \n StaticIota<__int128, 0> mm;\n \n std::inplace_vector<int, 10> tm3(std::from_range, mm); // { dg-error \"(from here|expansion of)\" }\n- // ref_view is not statically sized due pointer dereference\n- std::inplace_vector<int, 10> tr3(std::from_range, ref_view(mm));\n+ std::inplace_vector<int, 10> tr3(std::from_range, ref_view(mm)); // { dg-error \"(from here|expansion of)\" }\n }\n \n // { dg-error \"static assertion failed\" \"\" { target *-*-* } 0 }\ndiff --git a/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_range_neg.cc b/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_range_neg.cc\nindex 48d5b4c56f5..ea187761e5e 100644\n--- a/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_range_neg.cc\n+++ b/libstdc++-v3/testsuite/23_containers/inplace_vector/cons/from_range_neg.cc\n@@ -62,16 +62,14 @@ test_all()\n \n test_one(a1); // { dg-error \"from here\" }\n test_one(s1); // { dg-error \"from here\" }\n- // ref_view is not statically sized due pointer dereference\n- test_one(ref_view(a1));\n- test_one(a5 | std::views::adjacent<7> | std::views::elements<0>);\n+ test_one(ref_view(a1)); // { dg-error \"from here\" }\n+ test_one(a5 | std::views::adjacent<5> | std::views::elements<0>); // { dg-error \"from here\" }\n test_one(s5 | std::views::adjacent<5> | std::views::elements<0>); // { dg-error \"from here\" }\n \n test_five(a5); // { dg-error \"from here\" }\n test_five(s5); // { dg-error \"from here\" }\n- // ref_view is not statically sized due pointer dereference\n- test_five(ref_view(a5));\n- test_five(a7 | std::views::adjacent<3> | std::views::elements<0>);\n+ test_five(ref_view(a5)); // { dg-error \"from here\" }\n+ test_five(a7 | std::views::adjacent<3> | std::views::elements<0>); // { dg-error \"from here\" }\n test_five(s7 | std::views::adjacent<3> | std::views::elements<0>); // { dg-error \"from here\" }\n }\n \n", "prefixes": [ "v2", "4/4" ] }