Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2222011/?format=api
{ "id": 2222011, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2222011/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/adkUGggIiITbC-cp@tucnak/", "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": "<adkUGggIiITbC-cp@tucnak>", "date": "2026-04-10T15:15:38", "name": "c++, libstdc++: Implement LWG4483 - Multidimensional arrays are not supported by meta::reflect_constant_array and related functions", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "35791807f0ebfd9692fb6526f9e21d89e1307567", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/1.1/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/adkUGggIiITbC-cp@tucnak/mbox/", "series": [ { "id": 499480, "url": "http://patchwork.ozlabs.org/api/1.1/series/499480/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499480", "date": "2026-04-10T15:15:38", "name": "c++, libstdc++: Implement LWG4483 - Multidimensional arrays are not supported by meta::reflect_constant_array and related functions", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499480/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222011/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222011/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=YfX3nHBv;\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=YfX3nHBv", "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 4fsgPG3PwKz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 01:16:17 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 209764BA2E3B\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 15:16:15 +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 938704BA2E2A\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 15:15:45 +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-330-1viPWyxNOCGpac_tW1xYQg-1; Fri,\n 10 Apr 2026 11:15:43 -0400", "from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\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 A8C5B19560A6; Fri, 10 Apr 2026 15:15:42 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.33.241])\n by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id C01193000C16; Fri, 10 Apr 2026 15:15:41 +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 63AFFcL03991188\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Fri, 10 Apr 2026 17:15:39 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63AFFcCN3991187;\n Fri, 10 Apr 2026 17:15:38 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 209764BA2E3B", "OpenDKIM Filter v2.11.0 sourceware.org 938704BA2E2A" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 938704BA2E2A", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 938704BA2E2A", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775834145; cv=none;\n b=YnDlK8u/D4EA3v90rXsQOxMmCY0Gj8vkdK13NKbqUOMM1jE5O/QNzz7jiTbxKVvQWSx+GY8kAVz65aKphhP/l18CtN74yrGFTJdYUuHOQURRa+PjjDzu3DnMUHMJt32RfOq5nKtGoAUy/Rf5TftglxaDpb37bQRShfVjU0JTMwY=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775834145; c=relaxed/simple;\n bh=vwP4usqBus/Ucpxo0gfHp7o540AQQ3tRDp+e/jmCfS8=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=biSZbCS2GVy1dRMJpvl9L8BGSPMIwUO1Y3W/qICpOWd7eYxfE2jvFt/za+TD7OAOlLdd1DRMBa6zkJNJb6gpvH7ybijTMEdOJjX46e7txq+TKlnyHCYN9v1XRtQ0bX7RWRSXrP/cKrS+kNol88/x5Xo1O38F1T3eTOAXKaaKVKQ=", "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=1775834145;\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=q2tmNDnvLJL+uBhxtWfZlLoLuG/tZwTGSLlc9pOdhPs=;\n b=YfX3nHBvw162Zw4oZvQcHTAztdFajvMqC17FYL3yV68BVYDsDcHK4TR6MRSVxH46vLlEsx\n FMBk5GCnPr+ieWw1iqCk6HJfxxUN742DGbge0NI7CvJ2MKAC8kwyxOAXtU/YeWqdlz9UKr\n 6THQonzbdSMd7Q5+k01WQFP4D8SuRis=", "X-MC-Unique": "1viPWyxNOCGpac_tW1xYQg-1", "X-Mimecast-MFC-AGG-ID": "1viPWyxNOCGpac_tW1xYQg_1775834143", "Date": "Fri, 10 Apr 2026 17:15:38 +0200", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com>,\n Jonathan Wakely <jwakely@redhat.com>, Tomasz Kaminski <tkaminsk@redhat.com>", "Cc": "gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org", "Subject": "[PATCH] c++, libstdc++: Implement LWG4483 - Multidimensional arrays\n are not supported by meta::reflect_constant_array and related functions", "Message-ID": "<adkUGggIiITbC-cp@tucnak>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.4", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "rg1g00k6-LzafFlaSeuL6hEEOizNmsyQ5MsuY2iE08g_1775834143", "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 LWG4483. As written in the\napproved resolution, some checks are done on strip_array_types (valuet)\nrather than on valuet and one is skipped. Tomasz on IRC reasoned why\ninput_range should otherwise already ensure we see similar type, so just\nfor the possibility of fuzzed <meta> the patch adds some verification.\nAnd as the array cases are contiguous, instead of actually recursing (for\nwhich we'd need to have lvalue of the *it rather than prvalue) it just\nwalks the CONSTRUCTORs for the arrays and handles the elts in there\nrecursively.\nThe <meta> changes do exactly what the LWG4483 change says to do.\n\nTested on x86_64-linux, ok for trunk?\n\n2026-04-10 Jakub Jelinek <jakub@redhat.com>\n\n\t* reflect.cc (adjust_array_elt): New function.\n\t(get_range_elts): Implement LWG4483 - Multidimensional arrays are not\n\tsupported by meta::reflect_constant_array and related functions.\n\tHandle ARRAY_TYPE valuet. Don't unshare_expr in the class valuet case,\n\tget_template_param_object will unshare.\n\n\t* g++.dg/reflect/reflect_constant_array9.C: New test.\n\t* g++.dg/reflect/reflect_constant_array10.C: New test.\n\t* g++.dg/reflect/reflect_constant_array11.C: New test.\n\t* g++.dg/reflect/define_static_array6.C: New test.\n\t* g++.dg/reflect/define_static_object2.C: Uncomment older tests and\n\tfix them, add tests for unions.\n\n\t* include/std/meta (define_static_object): Adjust for LWG4483 changes\n\t- handle unions and arrays differently.\n\n\n\tJakub", "diff": "--- gcc/cp/reflect.cc.jj\t2026-04-10 08:45:20.716811803 +0200\n+++ gcc/cp/reflect.cc\t2026-04-10 15:32:30.747654790 +0200\n@@ -394,6 +394,47 @@ replace_parm_r (tree *tp, int *walk_subt\n static tree throw_exception (location_t, const constexpr_ctx *, const char *,\n \t\t\t tree, bool *, tree *);\n \n+/* Helper function for get_range_elts, handle adjustment of ARRAY_TYPE elts\n+ of a retvec. */\n+\n+static tree\n+adjust_array_elt (location_t loc, const constexpr_ctx *ctx, tree valuet,\n+\t\t tree expr, tree fun, bool *non_constant_p, tree *jump_target)\n+{\n+ if (TREE_CODE (valuet) == ARRAY_TYPE)\n+ {\n+ if (TREE_CODE (expr) != CONSTRUCTOR\n+\t || TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)\n+\treturn throw_exception (loc, ctx, \"reflect_constant_array failed\",\n+\t\t\t\tfun, non_constant_p, jump_target);\n+ unsigned int i;\n+ tree val;\n+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), i, val)\n+\t{\n+\t CONSTRUCTOR_ELT (expr, i)->value\n+\t = adjust_array_elt (loc, ctx, TREE_TYPE (valuet), val, fun,\n+\t\t\t\tnon_constant_p, jump_target);\n+\t if (*jump_target || *non_constant_p)\n+\t return NULL_TREE;\n+\t}\n+ return expr;\n+ }\n+ else if (INTEGRAL_TYPE_P (valuet))\n+ {\n+ if (TREE_CODE (expr) == INTEGER_CST)\n+\treturn expr;\n+ return throw_exception (loc, ctx, \"array element not a constant integer\",\n+\t\t\t fun, non_constant_p, jump_target);\n+ }\n+ expr = convert_reflect_constant_arg (valuet, expr);\n+ if (expr == error_mark_node)\n+ return throw_exception (loc, ctx, \"reflect_constant failed\",\n+\t\t\t fun, non_constant_p, jump_target);\n+ if (VAR_P (expr))\n+ expr = DECL_INITIAL (expr);\n+ return expr;\n+}\n+\n /* Kinds for get_range_elts. */\n \n enum get_range_elts_kind {\n@@ -513,23 +554,24 @@ get_range_elts (location_t loc, const co\n \t}\n if (kind == REFLECT_CONSTANT_ARRAY)\n \t{\n-\t if (!structural_type_p (valuet))\n+\t tree valuete = strip_array_types (valuet);\n+\t if (!structural_type_p (valuete))\n \t {\n \t if (!cxx_constexpr_quiet_p (ctx))\n \t\t{\n \t\t auto_diagnostic_group d;\n \t\t error_at (loc, \"%<reflect_constant_array%> argument with \"\n \t\t\t\t \"%qT which is not a structural type\", inst);\n-\t\t structural_type_p (valuet, true);\n+\t\t structural_type_p (valuete, true);\n \t\t}\n \t *non_constant_p = true;\n \t return NULL_TREE;\n \t }\n \t TREE_VEC_ELT (args, 0)\n-\t = build_stub_type (valuet,\n-\t\t\t cp_type_quals (valuet) | TYPE_QUAL_CONST,\n+\t = build_stub_type (valuete,\n+\t\t\t cp_type_quals (valuete) | TYPE_QUAL_CONST,\n \t\t\t false);\n-\t if (!is_xible (INIT_EXPR, valuet, args))\n+\t if (!is_xible (INIT_EXPR, valuete, args))\n \t {\n \t if (!cxx_constexpr_quiet_p (ctx))\n \t\terror_at (loc, \"%<reflect_constant_array%> argument with %qT \"\n@@ -551,7 +593,23 @@ get_range_elts (location_t loc, const co\n \t }\n \t tree referencet = TYPE_MAIN_VARIANT (instr);\n \t TREE_VEC_ELT (args, 0) = referencet;\n-\t if (!is_xible (INIT_EXPR, valuet, args))\n+\t if (valuete != valuet)\n+\t {\n+\t tree rt = referencet;\n+\t if (TYPE_REF_P (rt))\n+\t\trt = TREE_TYPE (rt);\n+\t if (!same_type_ignoring_top_level_qualifiers_p (valuet, rt))\n+\t\t{\n+\t\t if (!cxx_constexpr_quiet_p (ctx))\n+\t\t error_at (loc, \"%<reflect_constant_array%> argument with \"\n+\t\t\t\t \"%qT which is not compatible with %qT \"\n+\t\t\t\t \"%<std::ranges::range_reference_t%>\",\n+\t\t\t inst, referencet);\n+\t\t *non_constant_p = true;\n+\t\t return NULL_TREE;\n+\t\t}\n+\t }\n+\t else if (!is_xible (INIT_EXPR, valuet, args))\n \t {\n \t if (!cxx_constexpr_quiet_p (ctx))\n \t\terror_at (loc, \"%<reflect_constant_array%> argument with %qT \"\n@@ -595,12 +653,22 @@ get_range_elts (location_t loc, const co\n \telse\n \t {\n \t gcc_assert (kind == REFLECT_CONSTANT_ARRAY);\n+\t if (TREE_CODE (valuet) == ARRAY_TYPE)\n+\t {\n+\t\tretvec[i]\n+\t\t = adjust_array_elt (loc, ctx, valuet,\n+\t\t\t\t unshare_expr (retvec[i]), fun,\n+\t\t\t\t non_constant_p, jump_target);\n+\t\tif (*jump_target || *non_constant_p)\n+\t\t return NULL_TREE;\n+\t\tcontinue;\n+\t }\n \t tree expr = convert_reflect_constant_arg (valuet, retvec[i]);\n \t if (expr == error_mark_node)\n \t return throw_exception (loc, ctx, \"reflect_constant failed\",\n \t\t\t\t fun, non_constant_p, jump_target);\n \t if (VAR_P (expr))\n-\t expr = unshare_expr (DECL_INITIAL (expr));\n+\t expr = DECL_INITIAL (expr);\n \t retvec[i] = expr;\n \t }\n }\n--- gcc/testsuite/g++.dg/reflect/reflect_constant_array9.C.jj\t2026-04-10 14:58:28.892432782 +0200\n+++ gcc/testsuite/g++.dg/reflect/reflect_constant_array9.C\t2026-04-10 15:46:45.523823103 +0200\n@@ -0,0 +1,28 @@\n+// LWG4483 - Multidimensional arrays are not supported by\n+// meta::reflect_constant_array and related functions.\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+consteval auto\n+foo ()\n+{\n+ int a[3][3][3];\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\ta[i][j][k] = i + j + k;\n+ return std::meta::reflect_constant_array (a);\n+}\n+\n+static_assert (foo () == foo ());\n+static_assert (type_of (foo ()) == ^^const int [3][3][3]);\n+constexpr auto &m = [: foo () :];\n+consteval {\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\tif (m[i][j][k] != i + j + k)\n+\t throw 1;\n+}\n--- gcc/testsuite/g++.dg/reflect/reflect_constant_array10.C.jj\t2026-04-10 16:43:43.192287885 +0200\n+++ gcc/testsuite/g++.dg/reflect/reflect_constant_array10.C\t2026-04-10 16:57:20.060192312 +0200\n@@ -0,0 +1,53 @@\n+// LWG4483 - Multidimensional arrays are not supported by\n+// meta::reflect_constant_array and related functions.\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <ranges>\n+#include <meta>\n+\n+consteval auto\n+foo ()\n+{\n+ int a[3][3][3];\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\ta[i][j][k] = i + 3 * j + 9 * k;\n+ std::span <int[3][3]> b = a;\n+ return std::meta::reflect_constant_array (b);\n+}\n+\n+static_assert (foo () == foo ());\n+static_assert (type_of (foo ()) == ^^const int [3][3][3]);\n+constexpr auto &m = [: foo () :];\n+consteval {\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\tif (m[i][j][k] != i + 3 * j + 9 * k)\n+\t throw 1;\n+}\n+\n+consteval auto\n+bar ()\n+{\n+ int a[3][3][3];\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\ta[i][j][k] = i + 3 * j + 9 * k;\n+ std::span <int[3][3]> b = a;\n+ return std::meta::reflect_constant_array (b | std::views::reverse);\n+}\n+\n+static_assert (bar () == bar ());\n+static_assert (type_of (bar ()) == ^^const int [3][3][3]);\n+constexpr auto &n = [: bar () :];\n+consteval {\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\tif (n[i][j][k] != (2 - i) + 3 * j + 9 * k)\n+\t throw 1;\n+}\n--- gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C.jj\t2026-04-10 17:00:44.179663685 +0200\n+++ gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C\t2026-04-10 17:05:50.683365136 +0200\n@@ -0,0 +1,18 @@\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+// Test std::meta::reflect_constant_string.\n+\n+#include <meta>\n+#include <ranges>\n+#include <span>\n+\n+using namespace std::meta;\n+\n+struct A { int a, b; mutable int c; };\n+constexpr A aa[2] = { { 1, 2, 3 }, { 4, 5, 6 } };\n+constexpr auto a = reflect_constant_array (aa);\n+// { dg-error \"'reflect_constant_array' argument with 'std::ranges::range_value_t<const A \\\\\\[2\\\\\\]>' \\\\\\{aka 'A'\\\\\\} which is not a structural type\" \"\" { target *-*-* } .-1 }\n+struct B { constexpr B (int x, int y) : a (x), b (y) {} constexpr ~B () {} B (const B &) = delete; int a, b; };\n+constexpr B b[2][2] = { { { 1, 2 }, { 2, 3 } }, { { 3, 4 }, { 4, 5 } } };\n+constexpr auto c = reflect_constant_array (b);\n+// { dg-error \"'reflect_constant_array' argument with 'std::ranges::range_value_t<const B \\\\\\[2\\\\\\]\\\\\\[2\\\\\\]>' \\\\\\{aka 'B \\\\\\[2\\\\\\]'\\\\\\} which is not copy constructible\" \"\" { target *-*-* } .-1 }\n--- gcc/testsuite/g++.dg/reflect/define_static_array6.C.jj\t2026-04-10 15:44:52.229788936 +0200\n+++ gcc/testsuite/g++.dg/reflect/define_static_array6.C\t2026-04-10 15:52:38.099857297 +0200\n@@ -0,0 +1,27 @@\n+// LWG4483 - Multidimensional arrays are not supported by\n+// meta::reflect_constant_array and related functions.\n+// { dg-do compile { target c++26 } }\n+// { dg-additional-options \"-freflection\" }\n+\n+#include <meta>\n+\n+consteval auto\n+foo ()\n+{\n+ int a[3][3][3];\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\ta[i][j][k] = i + j + k;\n+ return std::define_static_array (a);\n+}\n+\n+static_assert (foo ().size () == 3);\n+constexpr auto *m = foo ().data ();\n+consteval {\n+ for (int i = 0; i < 3; ++i)\n+ for (int j = 0; j < 3; ++j)\n+ for (int k = 0; k < 3; ++k)\n+\tif (m[i][j][k] != i + j + k)\n+\t throw 1;\n+}\n--- gcc/testsuite/g++.dg/reflect/define_static_object2.C.jj\t2026-03-27 10:17:16.120298331 +0100\n+++ gcc/testsuite/g++.dg/reflect/define_static_object2.C\t2026-04-10 16:09:20.261858550 +0200\n@@ -1,3 +1,5 @@\n+// LWG4483 - Multidimensional arrays are not supported by\n+// meta::reflect_constant_array and related functions.\n // { dg-do compile { target c++26 } }\n // { dg-additional-options \"-freflection\" }\n // Test std::define_static_object.\n@@ -5,14 +7,19 @@\n #include <meta>\n \n constexpr int arr[]{1, 2, 3};\n-// LWG4483 use extract(reflect_constant_array())\n-// constexpr const int(*ptr)[3] = std::define_static_object(arr);\n-// static_assert( *ptr == std::define_static_array(arr).data() );\n-// static_assert( ptr = &std::meta::constant_of(arr) );\n+constexpr const int (*ptr)[3] = std::define_static_object (arr);\n+static_assert (*ptr == std::define_static_array (arr).data ());\n+static_assert (ptr == &[: std::meta::constant_of (^^arr) :]);\n \n constexpr int marr[3][3]{1, 2, 3};\n-// LWG4483 array are not structural so this fail\n-// constexpr const int(*mptr)[3][3] = std::define_static_object(marr);\n-// static_assert( *mptr == std::define_static_array(marr).data() );\n-// static_assert( mptr = &std::meta::constant_of(marr) );\n+constexpr const int (*mptr)[3][3] = std::define_static_object (marr);\n+static_assert (*mptr == std::define_static_array (marr).data ());\n+static_assert (mptr == &[: std::meta::constant_of (^^marr) :]);\n \n+union U { int a; long long b; };\n+constexpr U u = { .a = 42 };\n+constexpr const U *up = std::define_static_object (u);\n+static_assert (up->a == 42);\n+constexpr U v = { .b = 43LL };\n+constexpr const U *vp = std::define_static_object (v);\n+static_assert (vp->b == 43LL);\n--- libstdc++-v3/include/std/meta.jj\t2026-04-08 07:49:13.477647992 +0200\n+++ libstdc++-v3/include/std/meta\t2026-04-10 15:57:25.423013150 +0200\n@@ -682,11 +682,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n define_static_object(_Tp&& __t)\n {\n using _Up = remove_cvref_t<_Tp>;\n- if constexpr (meta::is_class_type(^^_Up))\n+ if constexpr (meta::is_class_type(^^_Up) || meta::is_union_type(^^_Up))\n \t{\n \t auto __cst = meta::reflect_constant(std::forward<_Tp>(__t));\n \t return std::addressof(meta::extract<const _Up&>(__cst));\n \t}\n+ else if constexpr (meta::is_array_type(^^_Up))\n+\t{\n+\t auto __cst = meta::reflect_constant_array(std::forward<_Tp>(__t));\n+\t return std::addressof(meta::extract<const _Up&>(__cst));\n+\t}\n else\n \treturn std::define_static_array(span(std::addressof(__t), 1)).data();\n }\n", "prefixes": [] }