120775 – [C++26] P2996R13 - Reflection (original) (raw)

| Comment 1 Andrew Pinski 2025-06-23 09:26:23 UTC . Comment 4 GCC Commits 2025-07-31 14:40:56 UTC The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:d46d8267b5a55e3194e879e691aeee1bc0648bed commit r16-2687-gd46d8267b5a55e3194e879e691aeee1bc0648bed Author: Marek Polacek <polacek@redhat.com> Date: Mon Jul 14 17:24:18 2025 -0400 c++: consteval blocks This patch implements consteval blocks, as specified by P2996. They aren't very useful without define_aggregate, but having a reviewed implementation on trunk would be great. consteval {} can be anywhere where a member-declaration or block-declaration can be. The expression corresponding to it is: [] -> void static consteval compound-statement () and it must be a constant expression. I've used cp_parser_lambda_expression to take care of most of the parsing. Since a consteval block can find itself in a template, we need a vehicle to carry the block for instantiation. Rather than inventing a new tree, I'm using STATIC_ASSERT. A consteval block can't return a value but that is checked by virtue of the lambda having a void return type. PR c++/120775 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_outermost_constant_expr): Use extract_call_expr. * cp-tree.h (CONSTEVAL_BLOCK_P, LAMBDA_EXPR_CONSTEVAL_BLOCK_P): Define. (finish_static_assert): Adjust declaration. (current_nonlambda_function): Likewise. * lambda.cc (current_nonlambda_function): New parameter. Only keep iterating if the function represents a consteval block. * parser.cc (cp_parser_lambda_expression): New parameter for consteval blocks. Use it. Set LAMBDA_EXPR_CONSTEVAL_BLOCK_P. (cp_parser_lambda_declarator_opt): Likewise. (build_empty_string): New. (cp_parser_next_tokens_are_consteval_block_p): New. (cp_parser_consteval_block): New. (cp_parser_block_declaration): Handle consteval blocks. (cp_parser_static_assert): Use build_empty_string. (cp_parser_member_declaration): Handle consteval blocks. * pt.cc (tsubst_stmt): Adjust a call to finish_static_assert. * semantics.cc (finish_fname): Warn for consteval blocks. (finish_static_assert): New parameter for consteval blocks. Set CONSTEVAL_BLOCK_P. Evaluate consteval blocks specially. gcc/testsuite/ChangeLog: * g++.dg/cpp26/consteval-block1.C: New test. * g++.dg/cpp26/consteval-block2.C: New test. * g++.dg/cpp26/consteval-block3.C: New test. * g++.dg/cpp26/consteval-block4.C: New test. * g++.dg/cpp26/consteval-block5.C: New test. * g++.dg/cpp26/consteval-block6.C: New test. * g++.dg/cpp26/consteval-block7.C: New test. * g++.dg/cpp26/consteval-block8.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com> Comment 5 Jakub Jelinek 2025-09-03 11:53:13 UTC Created attachment 62293 [details] gcc16-p3394r4-wip.patch Untested partial implementation of P3394R4, in particular the one which doesn't depend on the reflection branch stuff, so parsing of annotations and making sure it appertains to the right entities etc. Obviously, std::meta::is_annotation, std::meta::annotations_of and std::meta::annotations_of_with_type can't be implemented without the reflection stuff, and only when e.g. std::meta::reflect_constant is implemented. One thing not implemented in the patch (xfailed in the test) is that the paper allows annotations also on base-specifiers. This is novel to GCC, we ignore all attributes for those (with warning if any non-ignorable), and it is unclear on what tree to store those. Comment 6 Marek Polacek 2025-10-31 15:15:23 UTC TODO: The test from https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html still ICEs: base.C: In function ‘constexpr int f()’: base.C:15:81: internal compiler error: in cp_parser_splice_expression, at cp/parser.cc:6279 15 | B& b = d.[: std::meta::bases_of(^^D, std::meta::access_context::current())[0] :]; | ^~ 0x3011536 internal_error(char const*, ...) /home/mpolacek/src/forge/gcc/gcc/diagnostic-global-context.cc:787 0x301fe23 fancy_abort(char const*, int, char const*) /home/mpolacek/src/forge/gcc/gcc/diagnostics/context.cc:1806 0x6edd93 cp_parser_splice_expression /home/mpolacek/src/forge/gcc/gcc/cp/parser.cc:6279 Comment 7 Jakub Jelinek 2025-10-31 17:04:44 UTC (In reply to Marek Polacek from comment #6) > TODO: > > The test from > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html still > ICEs: > > base.C: In function ‘constexpr int f()’: > base.C:15:81: internal compiler error: in cp_parser_splice_expression, at > cp/parser.cc:6279 > 15 | B& b = d.[: std::meta::bases_of(^^D, > std::meta::access_context::current())[0] :]; > | > ^~ > 0x3011536 internal_error(char const*, ...) > /home/mpolacek/src/forge/gcc/gcc/diagnostic-global-context.cc:787 > 0x301fe23 fancy_abort(char const*, int, char const*) > /home/mpolacek/src/forge/gcc/gcc/diagnostics/context.cc:1806 > 0x6edd93 cp_parser_splice_expression > /home/mpolacek/src/forge/gcc/gcc/cp/parser.cc:6279 We should error on splicing reflections satisfying is_base, is_function_parameter, is_constructor, is_destructor etc. Comment 8 Desmond Gold 2025-11-03 04:06:01 UTC The following testcase ICEs on constexpr variable of consteval-only type inside a runtime-evaluated function using info = decltype(^^::); // OK constexpr info A {}; constexpr info B = ^^::; inline constexpr info C = ^^::; template struct S { // OK static constexpr info B {^^T}; // wont ICE during template definition // but ICE during template instantiation // (1) void wow() { constexpr info D {^^T}; } }; consteval void foo() { info A = ^^::; constexpr info B = ^^::; } constexpr void bar() { constexpr info A = ^^::; static constexpr info B = ^^::; } constexpr void tux() { if consteval { constexpr info A = ^^::; // static constexpr info B = ^^::; } } void qux() { // ICE // constexpr info A {}; // constexpr info B = ^^::; // static constexpr info C = ^^::; // OK: since it is constant evaluated foo(); consteval { bar(); } consteval { tux(); } // OK: since the runtime evaluation doesn't contain // the consteval branch tux(); // ICE // bar(); } // triggers ICE on (1) // template struct S ; When uncommenting the lines that are labeled ICE, each line will have the same following ICE output: :LL:CC: internal compiler error: Segmentation fault 57 | } | ^ 0x291e078 diagnostics::context::diagnostic_impl(rich_location*, diagnostics::metadata const*, diagnostics::option_id, char const*, __va_list_tag (*) [1], diagnostics::kind) ???:0 0x2912e6b internal_error(char const*, ...) ???:0 I run the testcase using https://godbolt.org/z/d8EY1TPdK. I don't know if this has been fixed since the branch is based on gcc-reflection-trunk-20251031. Comment 9 Desmond Gold 2025-11-03 05:08:24 UTC I tried to wrap the declarations using "if not consteval { ... }" which seems to silence the ICE: using info = decltype(^^::); consteval info identity(info i) { return i; } consteval int something_of(info) { return 10; } consteval void do_something(info) {} void fox() { if not consteval { constexpr info X {}; constexpr info A = ^^::; constexpr info B = identity(A); static constexpr info D = ^^::; static_assert(X == info{}); static_assert(A == ^^::); static_assert(B == ^^::); static_assert(D == ^^::); consteval { do_something(X); do_something(A); int H = something_of(A); constexpr int I = something_of(A); } } } However, the ICE resurfaces when referencing the constexpr variable of a consteval-only type: using info = decltype(^^::); consteval info identity(info i) { return i; } consteval int something_of(info) { return 10; } consteval void do_something(info) {} void fox() { if not consteval { constexpr info X {}; constexpr info A = ^^::; constexpr info B = identity(A); static constexpr info D = ^^::; static_assert(X == info{}); static_assert(A == ^^::); static_assert(B == ^^::); static_assert(D == ^^::); consteval { do_something(X); do_something(A); int H = something_of(A); constexpr int I = something_of(A); } // ICE // do_something(X); // do_something(A); // do_something_runtime(); // do_something_runtime(); // int C = something_of(A); // constexpr int E = something_of(A); // identity(A); // identity(B); } } Uncommenting the line one at a time will produce an ICE output https://godbolt.org/z/9xWhbYhbz Comment 10 Jakub Jelinek 2025-11-03 12:09:42 UTC Another thing to do is mangling. #include template <std::meta::info I> void foo (); void bar () { foo <^^::> (); foo <^^std::meta> (); //foo <std::meta::info {}> (); foo <std::meta::reflect_constant (42)> (); } The Bloomberg clang++ branch mangles these as _Z3fooIMn$EEvv _Z3fooIMnNSt3__14metaE$EEvv _Z3fooIMvLi42EEEvv where using $ in the mangled names is certainly wrong. GCC mangles it as _Z3fooIXL_Z2::EEEvv _Z3fooIXL_ZSt4metaEEEvv _Z3fooIXLi42EEEvv which is obviously wrong too, :: in a mangled name can't appear, and reflect_constant (42) argument shouldn't be mangled as a merge 42 constant IMHO. Plus on the commented out case we ICE. Comment 11 Jakub Jelinek 2025-11-03 18:49:39 UTC The #c8 ICE can be reduced to constexpr void foo () { if consteval { static constexpr auto a = ^^::; } } auto bar () { return &foo; } or template struct S { static constexpr auto s = ^^T; void foo () { constexpr auto s = ^^T; } }; template struct S ; The first ICE is during mangling, where we try to mangle the foo::a static variable, the second ICE is trying to output the S::s variable. Comment 12 Marek Polacek 2025-11-03 18:52:12 UTC (In reply to Jakub Jelinek from comment #11) > The #c8 ICE can be reduced to > > constexpr void foo () { if consteval { static constexpr auto a = ^^::; } } > auto bar () { return &foo; } > > or > > template struct S { static constexpr auto s = ^^T; void foo () > { constexpr auto s = ^^T; } }; > template struct S ; > > The first ICE is during mangling, where we try to mangle the foo::a static > variable, the second ICE is trying to output the S::s variable. I'll take a look at the latter now. Comment 13 Marek Polacek 2025-11-03 23:37:11 UTC Desmond, thanks a lot for reporting these bugs. I believe I fixed all the crashes, although this area is fraught with peril. The mangling part is still largely unresolved. The fix should propagate to Compiler Explorer before long. Comment 14 Marek Polacek 2025-11-04 02:01:22 UTC Indeed, I found more ICEs: ``` using info = decltype (^^int); void fn (info) {} ``` which results in internal compiler error: in adjust_one_expanded_partition_var, at cfgexpand.cc:1898 and is actually not so easy to fix. It should be rejected. But e.g., our own std::meta::exception::what() is also of consteval-only type and not an immediate function and it cannot be escalated and we shouldn't error on it. Then there's ``` template int fn (T) { return 4; } const int a = fn (^^int); ``` internal compiler error: in gimplify_expr, at gimplify.cc:21216 Comment 15 Jakub Jelinek 2025-11-04 10:24:13 UTC Had a quick look at g++.dg/reflect/p2996-17.C (the commented out stuff in there). The reason it doesn't work is that the reflect_constant and latest calls in static consteval void increment () { define_aggregate (substitute (^^Helper, { std::meta::reflect_constant (latest ()) }), {}); } aren't evaluated when evaluating the increment call at all, instead they are evaluated when we finish_compound_literal when parsing that function when trying to convert the initializer_list to some reflection_range usable in substitute. std::meta::reflect_constant (latest ()) is a constant expression and finish_compound_literal -> digest_init_flags -> digest_init_r -> process_init_constructor -> process_init_constructor_array -> massage_init_elt -> fold_non_dependent_init folds it to a reflection of constant 0. Now, this is mce_unknown evaluation. Shall all metafunctions be only handled if mce_true or mce_false (and define_aggregate/access_context::current only if mce_true as already done?)? diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index d6fe01ead1f..7ddb4b652cc 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -3845,6 +3845,13 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, *non_constant_p = true; return t; } + /* Don't evaluate metafunctions at all when mce_unknown, otherwise we + might fold those prematurely. See g++.dg/reflect/p2996-17.C. */ + if (ctx->manifestly_const_eval == mce_unknown) + { + *non_constant_p = true; + return t; + } ctx->global->metafns_called = true; tree e = process_metafunction (ctx, fun, t, non_constant_p, overflow_p, jump_target); diff --git a/gcc/testsuite/g++.dg/reflect/p2996-17.C b/gcc/testsuite/g++.dg/reflect/p2996-17.C index 6c2c6e31996..e9dabb0d799 100644 --- a/gcc/testsuite/g++.dg/reflect/p2996-17.C +++ b/gcc/testsuite/g++.dg/reflect/p2996-17.C @@ -25,10 +25,8 @@ struct TU_Ticket { constexpr int x = TU_Ticket::latest (); // x initialized to 0. consteval { TU_Ticket::increment (); } constexpr int y = TU_Ticket::latest (); // y initialized to 1. -// TODO: This one still doesn't work, doesn't call latest () again -// but uses cached 0 value. -//consteval { TU_Ticket::increment (); } -//constexpr int z = TU_Ticket::latest (); // z initialized to 2. +consteval { TU_Ticket::increment (); } +constexpr int z = TU_Ticket::latest (); // z initialized to 2. static_assert (x == 0); static_assert (y == 1); -//static_assert (z == 2); +static_assert (z == 2); fixes it. Do we want to do that? Doesn't regress anything else in the testsuite. https://forge.sourceware.org/marek/gcc/pulls/81 has it but haven't merged this yet. Comment 16 Jakub Jelinek 2025-11-04 10:33:32 UTC (In reply to Jakub Jelinek from comment #10) > The Bloomberg clang++ branch mangles these as > _Z3fooIMn$EEvv > _Z3fooIMnNSt3__14metaE$EEvv > _Z3fooIMvLi42EEEvv > where using $ in the mangled names is certainly wrong. > GCC mangles it as > _Z3fooIXL_Z2::EEEvv > _Z3fooIXL_ZSt4metaEEEvv > _Z3fooIXLi42EEEvv > which is obviously wrong too, :: in a mangled name can't appear, and > reflect_constant (42) argument shouldn't be mangled as a merge 42 constant > IMHO. Regarding mangling, we really need some agreed on mangling for the constants with std::meta::info type. Because #include template void foo () { } int v; void bar () { foo <42> (); foo <std::meta::reflect_constant (42)> (); foo <^^::> (); foo <std::meta::info {}> (); foo <^^int> (); foo <^^v> (); } is I think all valid and needs to mangle differently each time. And it needs to be a mangling that mangles the reflections which compare equal the same and those which compare differently using different strings. Comment 17 Jakub Jelinek 2025-11-04 10:37:01 UTC The really hard part will be e.g. how to mangle annotations, guess that one needs to be nth annotation of something, presumably direct base relationship could be similarly mangled as nth direct base of something, data member specification needs to mangle all 5 properties somehow, etc. Comment 19 Marek Polacek 2025-11-04 13:21:44 UTC (In reply to Jakub Jelinek from comment #15) > Had a quick look at g++.dg/reflect/p2996-17.C (the commented out stuff in > there). > The reason it doesn't work is that the reflect_constant and latest calls in > static consteval void increment () > { > define_aggregate (substitute (^^Helper, > { std::meta::reflect_constant (latest ()) > }), > {}); > } > aren't evaluated when evaluating the increment call at all, instead they are > evaluated > when we finish_compound_literal when parsing that function when trying to > convert the initializer_list to some reflection_range usable in substitute. > std::meta::reflect_constant (latest ()) is a constant expression and > finish_compound_literal -> digest_init_flags -> digest_init_r -> > process_init_constructor -> process_init_constructor_array -> > massage_init_elt -> fold_non_dependent_init folds it to a reflection of > constant 0. > Now, this is mce_unknown evaluation. Shall all metafunctions be only > handled if mce_true or mce_false (and > define_aggregate/access_context::current only if mce_true as already done?)? > > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > index d6fe01ead1f..7ddb4b652cc 100644 > --- a/gcc/cp/constexpr.cc > +++ b/gcc/cp/constexpr.cc > @@ -3845,6 +3845,13 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, > tree t, > *non_constant_p = true; > return t; > } > + /* Don't evaluate metafunctions at all when mce_unknown, otherwise we > + might fold those prematurely. See g++.dg/reflect/p2996-17.C. */ > + if (ctx->manifestly_const_eval == mce_unknown) > + { > + *non_constant_p = true; > + return t; > + } > ctx->global->metafns_called = true; > tree e = process_metafunction (ctx, fun, t, non_constant_p, > overflow_p, > jump_target); > diff --git a/gcc/testsuite/g++.dg/reflect/p2996-17.C > b/gcc/testsuite/g++.dg/reflect/p2996-17.C > index 6c2c6e31996..e9dabb0d799 100644 > --- a/gcc/testsuite/g++.dg/reflect/p2996-17.C > +++ b/gcc/testsuite/g++.dg/reflect/p2996-17.C > @@ -25,10 +25,8 @@ struct TU_Ticket { > constexpr int x = TU_Ticket::latest (); // x initialized to 0. > consteval { TU_Ticket::increment (); } > constexpr int y = TU_Ticket::latest (); // y initialized to 1. > -// TODO: This one still doesn't work, doesn't call latest () again > -// but uses cached 0 value. > -//consteval { TU_Ticket::increment (); } > -//constexpr int z = TU_Ticket::latest (); // z initialized to 2. > +consteval { TU_Ticket::increment (); } > +constexpr int z = TU_Ticket::latest (); // z initialized to 2. > static_assert (x == 0); > static_assert (y == 1); > -//static_assert (z == 2); > +static_assert (z == 2); > > fixes it. Do we want to do that? Doesn't regress anything else in the > testsuite. > https://forge.sourceware.org/marek/gcc/pulls/81 has it but haven't merged > this yet. Yeah, it may be the right thing. Please go ahead; if anything crops up, we'll address it. (You could merge it with the uid_sensitive_constexpr_evaluation_p case above.) Comment 20 Desmond Gold 2025-11-08 07:27:27 UTC I discovered another bug which involves initializing reflection type with null reflection within template body or during template instantiation: using info = decltype(^^int); inline constexpr info Ag {}; // ok consteval info return_null() { return info{}; } template struct S { static constexpr info Bt {^^::}; // ok static constexpr info Ct {}; // error during template definition static constexpr info Dt = return_null(); // error upon instantiation }; template struct S; // this triggers error on S::Dt int main() { template for (auto _ : {0}) { constexpr info A {}; // error upon immediate expansion } } Although it didn't ICE, it results in an error: :12:31: error: insufficient contextual information to determine type [-Wtemplate-body] 12 | static constexpr info Ct {}; // error during template definition | ^ : In instantiation of 'constexpr const info S::Dt': required from here :16:17: 16 | template struct S; | ^~~~~~ :13:43: error: insufficient contextual information to determine type 13 | static constexpr info Dt = return_null(); // error upon instantiation | ~~~~~~~~~~~^~ : In function 'int main()': :20:27: error: insufficient contextual information to determine type 20 | constexpr info A {}; // error upon immediate expansion | ^ https://godbolt.org/z/cfc3f47M6 There is no error in Clang Reflection Branch when compiling this code. Comment 21 Desmond Gold 2025-11-08 08:06:11 UTC Bug #2: results in an error when using a constexpr structured binding to a constexpr object whose subobjects are consteval-only (reflection value). using info = decltype(^^int); struct Point { int x; int y; }; struct Info { info i; info j; }; struct Mixed { int x; info j; }; void foo() { constexpr Point p {3, 4}; constexpr auto [px, py] = p; static_assert(px == 3); static_assert(py == 4); constexpr Info i {^^::, ^^int}; constexpr auto [i1, i2] = i; static_assert(i.i == ^^::); static_assert(i.j == ^^int); static_assert(i1 == ^^::); // error static_assert(i2 == ^^int); // error constexpr Mixed m {4, ^^::}; // constexpr auto [m1, m2] = m; (another ICE :<) constexpr int arr[] {6, 7}; constexpr auto [arr0, arr1] = arr; static_assert(arr0 == 6); static_assert(arr1 == 7); constexpr info info_arr[] {^^::, ^^int}; constexpr auto [ii1, ii2] = info_arr; static_assert(info_arr[0] == ^^::); static_assert(info_arr[1] == ^^int); static_assert(ii1 == ^^::); // error static_assert(ii2 == ^^int); // error } : In function 'void foo()': :29:22: error: non-constant condition for static assertion 29 | static_assert(i1 == ^^::); | ~~~^~~~~~~ :29:19: error: the value of 'i1' is not usable in a constant expression 29 | static_assert(i1 == ^^::); | ^~ :25:21: note: 'i1' used in its own initializer 25 | constexpr auto [i1, i2] = i; | ^~ :30:22: error: non-constant condition for static assertion 30 | static_assert(i2 == ^^int); | ~~~^~~~~~~~ :30:19: error: the value of 'i2' is not usable in a constant expression 30 | static_assert(i2 == ^^int); | ^~ :25:25: note: 'i2' used in its own initializer 25 | constexpr auto [i1, i2] = i; | ^~ :45:23: error: non-constant condition for static assertion 45 | static_assert(ii1 == ^^::); | ~~~~^~~~~~~ :45:19: error: the value of 'ii1' is not usable in a constant expression 45 | static_assert(ii1 == ^^::); | ^~~ :41:21: note: 'ii1' used in its own initializer 41 | constexpr auto [ii1, ii2] = info_arr; | ^~~ :46:23: error: non-constant condition for static assertion 46 | static_assert(ii2 == ^^int); | ~~~~^~~~~~~~ :46:19: error: the value of 'ii2' is not usable in a constant expression 46 | static_assert(ii2 == ^^int); | ^~~ :41:26: note: 'ii2' used in its own initializer 41 | constexpr auto [ii1, ii2] = info_arr; | https://godbolt.org/z/hq1rf7aKv Comment 22 Desmond Gold 2025-11-08 08:16:50 UTC another one: template void foo() { constexpr int i = [:reflect_constant(5):]; constexpr info f = reflect_constant_array( std::vector{1, 2, 3} ); constexpr auto& arr = [:f:]; constexpr auto& arr2 = [:reflect_constant_array( std::vector{1, 2, 3} ):]; } void bar() { constexpr auto& arr = [:reflect_constant_array( std::vector{1, 2, 3} ):]; } results in ICE when splicing 'reflect_constant_array(...)' inside template definition (initializing 'arr2' inside 'foo'): : In function 'void foo()': :11:52: internal compiler error: in get_range_elts, at cp/reflect.cc:355 11 | constexpr auto& arr2 = [:reflect_constant_array( | ~~~~~~~~~~~~~~~~~~~~~~^ 12 | std::vector{1, 2, 3} | ~~~~~~~~~~~~~~~~~~~~ 13 | ):]; | ~ 0x29213e8 diagnostics::context::diagnostic_impl(rich_location*, diagnostics::metadata const*, diagnostics::option_id, char const*, __va_list_tag (*) [1], diagnostics::kind) ???:0 0x29161db internal_error(char const*, ...) ???:0 0xb13bf4 fancy_abort(char const*, int, char const*) ???:0 0xdd40ec process_metafunction(constexpr_ctx const*, tree_node*, tree_node*, bool*, bool*, tree_node**) ???:0 0xb80a41 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*, value_cat, bool*, bool*, tree_node**) ???:0 0xb92743 cxx_constant_value(tree_node*, tree_node*, int) ???:0 0xdc5c7c splice(tree_node*) ???:0 0xd502d3 c_parse_file() ???:0 0xed74c9 c_common_parse_file() ???:0 https://godbolt.org/z/qP8988P5b Comment 23 Marek Polacek 2025-11-11 15:59:03 UTC Thanks again. #20 and #21 are now fixed; #22 not yet. Comment 24 Jakub Jelinek 2025-11-11 16:02:56 UTC (In reply to Desmond Gold from comment #22) > https://godbolt.org/z/qP8988P5b #include using namespace std::meta; template void foo () { constexpr int i = [: reflect_constant (5) :]; constexpr info f = reflect_constant_array (std::vector { 1, 2, 3 }); constexpr auto &arr = [: f :]; constexpr auto &arr2 = [: reflect_constant_array (std::vector { 1, 2, 3 }) :]; } void bar () { constexpr auto &arr = [: reflect_constant_array (std::vector { 1, 2, 3 }) :]; } int main () { } splice calls cxx_constant_value when processing_template_decl, that looks unexpected, I think normally we'd call fold_non_dependent_expr instead when processing_template_decl. Anyway, the ICE is because get_range_elts sees the processing_template_decl specific trees like CAST_EXPR with std::vector type instead of the expected const std::vector &&. Comment 25 Marek Polacek 2025-11-11 16:07:47 UTC (In reply to Jakub Jelinek from comment #24) > (In reply to Desmond Gold from comment #22) > > https://godbolt.org/z/qP8988P5b > > #include > > using namespace std::meta; > > template > void > foo () > { > constexpr int i = [: reflect_constant (5) :]; > constexpr info f = reflect_constant_array (std::vector { 1, 2, 3 }); > constexpr auto &arr = [: f :]; > constexpr auto &arr2 = [: reflect_constant_array (std::vector { 1, 2, 3 }) > :]; > } > > void > bar () > { > constexpr auto &arr = [: reflect_constant_array (std::vector { 1, 2, 3 }) > :]; > } > > int > main () > { > } > > splice calls cxx_constant_value when processing_template_decl, that looks > unexpected, I think normally we'd call fold_non_dependent_expr instead when > processing_template_decl. > Anyway, the ICE is because get_range_elts sees the processing_template_decl > specific trees like CAST_EXPR with std::vector type instead of the > expected const std::vector &&. Yes, but I got a crash on the gcc_checking_assert (TYPE_REF_P (type)); even when I do tsubst the arg, which is why I haven't fixed this yet :( Comment 27 Marek Polacek 2025-11-11 16:49:58 UTC (In reply to Jakub Jelinek from comment #26) > https://forge.sourceware.org/marek/gcc/pulls/96 seems to fix that, shall I > merge that or do you want something else? Could we do just - refl = cxx_constant_value (refl); + refl = fold_non_dependent_expr (refl, tf_warning_or_error, + /*manifestly_const_eval=*/true); ? Comment 28 Jakub Jelinek 2025-11-11 16:57:08 UTC (In reply to Marek Polacek from comment #27) > (In reply to Jakub Jelinek from comment #26) > > https://forge.sourceware.org/marek/gcc/pulls/96 seems to fix that, shall I > > merge that or do you want something else? > > Could we do just > > - refl = cxx_constant_value (refl); > + refl = fold_non_dependent_expr (refl, tf_warning_or_error, > + /*manifestly_const_eval=*/true); > > ? I think we can't. One, I think we need to handle the processing_template_decl case more carefully, if it isn't constant, just revert to building SPLICE_EXPR, while for !processing_template_decl we want to error. And fold_non_dependent_expr calls maybe_constant_value instead of cxx_constant_value, so while it is mce_true as well, it doesn't report errors, just silently returns non-constant. Comment 29 Marek Polacek 2025-11-11 17:26:34 UTC If REFL is non-dependent, then I think we should error even in a template, because there won't be a valid instantiation? Fair enough on the second point, but that could be fixed by adding if (require_constant_expression (refl)) cxx_constant_value (refl); maybe? Comment 30 Jakub Jelinek 2025-11-11 17:48:58 UTC Playing around, just pure - refl = cxx_constant_value (refl); + refl = fold_non_dependent_expr (refl, tf_warning_or_error, true); fixes the testcase too (and nothing in testsuite fails), but I'd think I'd still prefer - refl = cxx_constant_value (refl); + if (processing_template_decl) + refl = fold_non_dependent_expr (refl, tf_warning_or_error, true); + else + refl = cxx_constant_value (refl); because it can give better diagnostics outside of template. Comment 31 Marek Polacek 2025-11-11 17:50:42 UTC OK, I'm fine with #30. Thanks. Comment 32 friedkeenan 2025-11-12 10:36:49 UTC Not sure if this is already a known bug (I don't think it's listed here at least, but if I'm wrong, then I apologize), but the following code currently causes an ICE: #include template void func() { constexpr auto ctx = std::meta::access_context::unprivileged(); } Godbolt link: https://godbolt.org/z/r1xE6b6Yx The ICE also occurs with ::unchecked() in place of ::unprivileged(), but not with ::current(). The ICE only occurs when the function is a template function, and only when the ctx variable is constexpr, whether it's static or not. (Also thank you all for your work, it is both very impressive and very appreciated!) Comment 33 Jakub Jelinek 2025-11-12 12:28:33 UTC (In reply to friedkeenan from comment #32) > Not sure if this is already a known bug (I don't think it's listed here at > least, but if I'm wrong, then I apologize), but the following code currently > causes an ICE: > > #include > > template > void func() { > constexpr auto ctx = std::meta::access_context::unprivileged(); > } Doesn't actually need anything from in that case, struct S { using info = decltype (^^int); consteval S (info x) noexcept : a {x} { } consteval S (const S &) = default; static consteval S bar () noexcept { return S { info {} }; } info a; }; template void foo () { constexpr auto ctx = S::bar (); } ICEs too. Commenting out the defaulted copy constructor fixes this. And, it doesn't need reflection either, struct S { consteval S (int x) noexcept : a {x} { } consteval S (const S &) = default; static consteval S bar () noexcept { return S { int {} }; } int a; }; template void foo () { constexpr auto s = S::bar (); } ICEs too and doesn't need reflection branch, so let me file that separately. Comment 34 friedkeenan 2025-11-12 12:35:08 UTC (In reply to Jakub Jelinek from comment #33) > And, it doesn't need reflection either, > struct S { > consteval S (int x) noexcept : a {x} { } > consteval S (const S &) = default; > static consteval S bar () noexcept { return S { int {} }; } > int a; > }; > > template > void > foo () > { > constexpr auto s = S::bar (); > } > ICEs too and doesn't need reflection branch, so let me file that separately. Ah, strange. I guess it might be out of scope of the reflection branch then, yeah. Thanks for taking a look! Comment 36 Boris Staletic 2025-11-14 18:37:53 UTC I've gone through all of the examples in P2996 and found five errors preventing Marek's fork from compiling all of them. See: https://godbolt.org/z/chYM1zPbh To elaborate: - The first error is not related to reflections, but has to do with constexpr reference to local. - The second error, I'm not sure, but could also be outside of the scope of reflections and more to do with expansion statements. - The third error is finicky. Changing the formatting can make it go away. It prevents, sometimes, expressions like `obj.[:members[Is]:]...`, where `Is` is a pack from an index sequence. - The fourth says `obj.[:member_refl:]` is ambiguous when `obj` has multiple members named `_`. According to P2996, name lookup shouldn't be performed. - Finally, there's an ICE when trying to call `access_context::unchecked()` from inside a template. Regarding "no name lookup", P2996 says this: > Note that a “member access splice” like s.[:member_number(1):] is a more direct > member access mechanism than the traditional syntax. It doesn’t involve member > name lookup, access checking, or — if the spliced reflection value represents a > member function — overload resolution. I also have a library that relies on C++26 reflections, but I have not yet tried to compile it with Marek's fork, as patterns like those that trigger the second and third error above do show up in my library. Either way, the library is available at: https://codeberg.org/bstaletic/pymetabind Comment 37 Jakub Jelinek 2025-11-14 19:30:30 UTC (In reply to Boris Staletic from comment #36) > I've gone through all of the examples in P2996 and found five errors > preventing Marek's fork from compiling all of them. > > See: https://godbolt.org/z/chYM1zPbh > > To elaborate: > > - The first error is not related to reflections, but has to do with > constexpr reference to local. > - The second error, I'm not sure, but could also be outside of the scope of > reflections and more to do with expansion statements. > - The third error is finicky. Changing the formatting can make it go away. > It prevents, sometimes, expressions like `obj.[:members[Is]:]...`, where > `Is` is a pack from an index sequence. > - The fourth says `obj.[:member_refl:]` is ambiguous when `obj` has multiple > members named `_`. According to P2996, name lookup shouldn't be performed. > - Finally, there's an ICE when trying to call `access_context::unchecked()` > from inside a template. > > Regarding "no name lookup", P2996 says this: > > > Note that a “member access splice” like s.[:member_number(1):] is a more direct > > member access mechanism than the traditional syntax. It doesn’t involve member > > name lookup, access checking, or — if the spliced reflection value represents a > > member function — overload resolution. > > I also have a library that relies on C++26 reflections, but I have not yet > tried to compile it with Marek's fork, as patterns like those that trigger > the second and third error above do show up in my library. > Either way, the library is available at: > https://codeberg.org/bstaletic/pymetabind The ICE in tsubst_expr is likely PR122658. Regarding some cases of expansion statements, there is https://gcc.gnu.org/pipermail/gcc-patches/2025-November/700380.html patch waiting for review, but more importantly expansion statements are known not to work with define_static_array directly in the current expansion statement definition, see https://github.com/cplusplus/CWG/issues/805 I have a patch in testing for that but I think the CWG needs to decide first what they want. A workaround that works for me is template for (constexpr auto m : (const std::span <const ...> define_static_array (...)). The "_" case is a known issue, see e.g. https://forge.sourceware.org/marek/gcc/src/branch/reflection/gcc/testsuite/g++.dg/reflect/member15.C mentioning it or the https://forge.sourceware.org/marek/gcc/commit/c9bc89c30bd7ade9e9c7d5d908c0d3272675ec08 commit message for details, I hope we'll work on that next week. Comment 38 Boris Staletic 2025-11-14 20:06:54 UTC Jakub, thanks for the quick reply. So, the ICE, the the expansion statements and the `_`-named members aside (as those are known and being worked on), I see that I failed to provide a repro for error 3 from my previous comment. I don't know what happened and why it started working... Anyway, that error was supposed to be distilled from P2996's "struct to tuple" example. Here's the actual error: https://godbolt.org/z/dW4vbdKeM If the line is changed from return std::make_tuple(t.[:members:]...); to return std::make_tuple(t.*&[:members:]...); The error changes to "lvalue required as unary '&' operand". If this is known as well and there's a workaround, I can try the gcc reflection impl on my library over the weekend. Comment 41 Boris Staletic 2025-11-24 03:00:01 UTC > Regarding https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120775#c38 that testcase doesn't fail on godbolt now. True. I can't repro it either. Though the "lvalue required as unary '&' operand" in case of `t.*&[:member:]` still remains. I managed to reduce the testcase further: ``` #include struct S { int x; }; template auto test_address_of_spliced_member(T) { &[:nonstatic_data_members_of(^^T, std::meta::access_context::current())[0]:]; } int main() { test_address_of_spliced_member(S{}); } ``` I have also ran into a new problem: ``` #include template<size_t...Is> void test1() { static constexpr std::meta::info types[]{^^int}; [](typename[:types[Is]:]... args) {}; } ``` The error says "expansion pattern '[: types[Is] :]' contains no parameter packs". I will attach both test cases as preprocessed files. Comment 42 Boris Staletic 2025-11-24 03:07:54 UTC Created attachment 62890 [details] pack expansion containing a splice expression, containing a range indexed by a pack of size_t Without `static` in `types` declaration, the error is: ``` foo.cpp:6:18: error: use of local variable with automatic storage from containing function [-Wtemplate-body] 6 | [](typename[:types[Is]:]... args) {}; | ^~~~~ foo.cpp:5:31: note: 'constexpr const std::meta::info types [1]' declared here 5 | constexpr std::meta::info types[]{^^int}; | ^~~~~ foo.cpp:6:29: error: reflection not usable in a splice type before '...' token [-Wtemplate-body] 6 | [](typename[:types[Is]:]... args) {}; | ^~~ ``` With `static` in the declaration of `types`, the error becomes ``` foo.cpp:6:33: error: expansion pattern '[: types[Is] :]' contains no parameter packs [-Wtemplate-body] 6 | [](typename[:types[Is]:]... args) {}; | ^~~~ ``` Comment 43 Boris Staletic 2025-11-24 03:13:04 UTC Created attachment 62891 [details] splice expression value category Error from the value category testcase: ``` bar.cpp: In instantiation of 'auto test_address_of_spliced_member(T) [with T = S]': required from here bar.cpp:11:35: 11 | test_address_of_spliced_member(S{}); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ bar.cpp:7:5: error: lvalue required as unary '&' operand 7 | &[:nonstatic_data_members_of(^^T, std::meta::access_context::current())[0]:]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Comment 44 Marek Polacek 2025-11-24 15🔞03 UTC Thanks a lot for the test cases! We should be able to take care of them once Reflection is merged (I don't want to change the branch when it's under review). | | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------- | ---------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------- | ---------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------- | ------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------ | ----------------------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | -------------------- | ---------------------------------------------------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |