Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217750/?format=api
{ "id": 2217750, "url": "http://patchwork.ozlabs.org/api/patches/2217750/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/acp75QV2Nfb_qM94@tucnak/", "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": "<acp75QV2Nfb_qM94@tucnak>", "list_archive_url": null, "date": "2026-03-30T13:34:29", "name": "[RFC] libstdc++: Attempt to implement LWG4537 - Improve define_static_array", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "809e900ac30c3c2d46e18a7daa3b498a22c3792e", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/acp75QV2Nfb_qM94@tucnak/mbox/", "series": [ { "id": 498032, "url": "http://patchwork.ozlabs.org/api/series/498032/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498032", "date": "2026-03-30T13:34:29", "name": "[RFC] libstdc++: Attempt to implement LWG4537 - Improve define_static_array", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498032/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217750/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217750/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=Rxp5gIXU;\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=Rxp5gIXU", "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.129.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 4fkshg398sz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 00:36:03 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4CBB24BB58D4\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 13:36:01 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id ED2BD4BAD16D\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 13:34:37 +0000 (GMT)", "from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-bdZPWjrTP6uGwsDkRwtPZg-1; Mon,\n 30 Mar 2026 09:34:35 -0400", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 3B05219560A1; Mon, 30 Mar 2026 13:34:34 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.32.9])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 36F2118001FE; Mon, 30 Mar 2026 13:34:33 +0000 (UTC)", "from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 62UDYUAh576848\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Mon, 30 Mar 2026 15:34:30 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 62UDYU7l576847;\n Mon, 30 Mar 2026 15:34:30 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 4CBB24BB58D4", "OpenDKIM Filter v2.11.0 sourceware.org ED2BD4BAD16D" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org ED2BD4BAD16D", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org ED2BD4BAD16D", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774877678; cv=none;\n b=TpVRiYzaTxIkcobMXtA6lgubg7IvYnd7TZ5Z8IRjEwJbtr70yLxkPM0+1p/IexTuIEo4jceu2uuKh/ADJesMQGbisXFnEn28x+aIBY5e+asiaIbMfUpv3SDT10jRQUjSe44vKLK8rna9e7DrGKnnNkqAcKoITQYPZ7NxB/rMKIk=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774877678; c=relaxed/simple;\n bh=trBImIbQ8VQQQh0ygzd5DDnqVUHovcz6xuqs5Jzu1po=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=fyE8HXd0o06t9RSWeOmQH/N1XYhiWMR3hZgqPQKr99wGhPge8cXywGkL1cxfq2lrFMae8PxMdT1N70rjCSL96QiW5tVdnmAvq9fh3VGHKzVC3mpybPOyRJEr6Ycb9Wtq5RAErtzyg0quDxTDDnJapikS7BDVdpAjW5HvDCdCpdo=", "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=1774877677;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=o0PQM8fZqqsIODU4NYfpUpSfch6VMbyD9Q+tqCqeGo8=;\n b=Rxp5gIXU66IttH+c3XESh+yutNDZWyi+cPhqlP/Y+AX6t5y2eM0wn3D1t4NFAvJFonyqvm\n h9A6bDNlpWmia2k90zs7yFmDewBsbN+8V65xDwenahIg3VKqgcVLxW4FSvu9mzS99hV+BS\n fCFB/jYB8712/VT12EmvLCfuFVFN8nk=", "X-MC-Unique": "bdZPWjrTP6uGwsDkRwtPZg-1", "X-Mimecast-MFC-AGG-ID": "bdZPWjrTP6uGwsDkRwtPZg_1774877674", "Date": "Mon, 30 Mar 2026 15:34:29 +0200", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Jonathan Wakely <jwakely@redhat.com>,\n Tomasz Kaminski <tkaminsk@redhat.com>, Marek Polacek <polacek@redhat.com>", "Cc": "gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org", "Subject": "[RFC PATCH] libstdc++: Attempt to implement LWG4537 - Improve\n define_static_array", "Message-ID": "<acp75QV2Nfb_qM94@tucnak>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "OaZIyz1Hdqx_G2NTQaWuW6eS7to7KQaitagKLb4Xn78_1774877674", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "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": "Jakub Jelinek <jakub@redhat.com>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Hi!\n\nThe following patch attempts to implement\nhttps://cplusplus.github.io/LWG/lwg-active.html#4537\nNot sure if the concept has the best name or there could be some better\nimplementation, nor if having auto return type on define_static_array\nis acceptable.\n\nI've added tests for the returned type (though am not sure if that\nis correct in all cases or if we don't need further tests).\n\nIn any case, this patch breaks\n\nFAIL: g++.dg/reflect/range_args.C -std=c++26 (test for excess errors)\nExcess errors:\n/usr/src/gcc/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/meta:652:25: error: no match for call to '(const std::ranges::__access::_Size) (std::ranges::filter_view<std::span<const char>, bool (*)(char)>&)'\n/usr/src/gcc/gcc/testsuite/g++.dg/reflect/range_args.C:75:33: error: non-constant condition for static assertion\n/usr/src/gcc/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/meta:652:25: error: no match for call to '(const std::ranges::__access::_Size) (std::ranges::take_while_view<std::span<const char>, bool (*)(char)>&)'\n/usr/src/gcc/gcc/testsuite/g++.dg/reflect/range_args.C:76:33: error: non-constant condition for static assertion\nThis is on\nconstexpr std::span<const char> vv = \"abcd01234\";\nconstexpr bool not_digit(char c) {\n return c < '0' || c > '9';\n}\n\nstatic_assert (test_value_range (vv | std::views::filter (not_digit))); // bidirectional\nstatic_assert (test_value_range (vv | std::views::take_while (not_digit))); // non-common\n\nDunno if this is a filter_view/take_while_view bug, something not thought\nout during LWG4537 resolution, bug in the concept or its use, something\nelse.\n\n2026-03-30 Jakub Jelinek <jakub@redhat.com>\n\n\t* include/std/meta (std::meta::__detail::__statically_sized): New\n\tconcept.\n\t(std::meta::define_static_array): Change return type to auto. Use\n\t__detail::__statically_sized<_Rg> ? ranges::size(__r) : dynamic_extent\n\tas second template argument to span, for empty span construct\n\tspan from static_cast<const _Tp*>(nullptr), 0 instead of default\n\tconstructing it.\n\n\t* g++.dg/reflect/define_static_array1.C (l): Another variable\n\twith define_static_array test from array<int, 0>.\n\tAdd static assertions for types of the define_static_array results.\n\n\n\tJakub", "diff": "--- libstdc++-v3/include/std/meta.jj\t2026-03-30 12:57:50.289580921 +0200\n+++ libstdc++-v3/include/std/meta\t2026-03-30 15:02:54.818234758 +0200\n@@ -632,18 +632,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n return meta::extract<const ranges::range_value_t<_Rg>*>(__str);\n }\n \n+ namespace __detail\n+ {\n+ template<typename _Rg>\n+ concept __statically_sized\n+ = requires(_Rg&& __r) {\n+\tstatic_cast<char(*)[static_cast<size_t>(ranges::size(__r))\n+\t\t\t >= 0]>(nullptr);\n+ };\n+ } // namespace __detail\n+\n template<ranges::input_range _Rg>\n- consteval span<const ranges::range_value_t<_Rg>>\n+ consteval auto\n define_static_array(_Rg&& __r)\n {\n using _Tp = ranges::range_value_t<_Rg>;\n+ constexpr size_t __extent\n+\t= __detail::__statically_sized<_Rg>\n+\t ? ranges::size(__r) : dynamic_extent;\n auto __array = meta::reflect_constant_array(__r);\n auto __type = meta::type_of(__array);\n if (meta::is_array_type(__type))\n-\treturn span<const _Tp>(meta::extract<const _Tp*>(__array),\n-\t\t\t meta::extent(__type, 0U));\n+\treturn span<const _Tp, __extent>(meta::extract<const _Tp*>(__array),\n+\t\t\t\t\t meta::extent(__type, 0U));\n else\n-\treturn span<const _Tp>();\n+\treturn span<const _Tp, __extent>(static_cast<const _Tp*>(nullptr),\n+\t\t\t\t\t 0);\n }\n \n template<class _Tp>\n--- gcc/testsuite/g++.dg/reflect/define_static_array1.C.jj\t2026-03-27 10:17:16.120298331 +0100\n+++ gcc/testsuite/g++.dg/reflect/define_static_array1.C\t2026-03-30 15:19:15.286549988 +0200\n@@ -22,6 +22,7 @@ constexpr auto h = std::define_static_ar\n constexpr auto i = std::define_static_array (std::vector <V> { V { 1, 2, 3 }, V { 2, 3, 4 }, V { 3, 4, 5 } });\n constexpr auto j = std::define_static_array (std::vector <long long> {});\n constexpr auto k = std::define_static_array (std::meta::nonstatic_data_members_of (^^V, std::meta::access_context::current ()));\n+constexpr auto l = std::define_static_array (std::array <int, 0> {});\n static_assert (a.data () == std::define_static_string (\"abcd\") && a.size () == 5);\n static_assert (b.data () == std::define_static_string (U\"abcd\\0ef\\N{LATIN CAPITAL LETTER AE}\")\n \t && b.size () == sizeof (U\"abcd\\0ef\\N{LATIN CAPITAL LETTER AE}\") / sizeof (char32_t));\n@@ -40,6 +41,19 @@ static_assert (h.data () == std::define_\n static_assert (i.size () == 3);\n static_assert (j.data () == nullptr && j.size () == 0);\n static_assert (k.size () == 3 && k[0] == ^^V::a && k[1] == ^^V::b && k[2] == ^^V::c);\n+static_assert (l.data () == nullptr && l.size () == 0);\n+static_assert (type_of (^^a) == ^^const std::span <const char, 5>);\n+static_assert (type_of (^^b) == ^^const std::span <const char32_t, sizeof (U\"abcd\\0ef\\N{LATIN CAPITAL LETTER AE}\") / sizeof (char32_t)>);\n+static_assert (type_of (^^c) == ^^const std::span <const char, std::dynamic_extent>);\n+static_assert (type_of (^^d) == ^^const std::span <const int, 4>);\n+static_assert (type_of (^^e) == ^^const std::span <const float, 6>);\n+static_assert (type_of (^^f) == ^^const std::span <const int, std::dynamic_extent>);\n+static_assert (type_of (^^g) == ^^const std::span <const int, std::dynamic_extent>);\n+static_assert (type_of (^^h) == ^^const std::span <const int, std::dynamic_extent>);\n+static_assert (type_of (^^i) == ^^const std::span <const V, std::dynamic_extent>);\n+static_assert (type_of (^^j) == ^^const std::span <const long long, std::dynamic_extent>);\n+static_assert (type_of (^^k) == ^^const std::span <const std::meta::info, std::dynamic_extent>);\n+static_assert (type_of (^^l) == ^^const std::span <const int, 0>);\n \n int\n main ()\n", "prefixes": [ "RFC" ] }