>>>> I try compile reflection test code with std module without
>>>> -freflection but build std module with -freflection. An ICE
>>>> accur when I do this.
>>>
>>> Can you give us instruction to reproduce the crash?
>>
>> The following is my reproduction record.
>>
>> $ cat main.cc
>> import std;
>>
>> template <typename T>
>> consteval auto nsdm_of() {
>> const auto ctx = std::meta::access_context::current();
>> return
>> std::define_static_array(std::meta::nonstatic_data_members_of(^^T, ctx));
>> }
>>
>> int main() {
>> constexpr auto I = nsdm_of<std::vector<int>>();
>> }
>>
>> $ g++ -B. -std=c++26 -fmodules -freflection -fmodule-only
>> --compile-std-module
>> $ g++ -B. -std=c++26 -fmodules main.cc
>
> Seems like we want to reject the import based on a dialect mismatch,
> i.e. check flag_reflection in module.cc get_dialect.
Thanks, the new patch make the reflection in dialect with flag_reflection.
>
>> main.cc: In function 'consteval auto nsdm_of()':
>> main.cc:5:33: internal compiler error: Segmentation fault
>> 5 | const auto ctx = std::meta::access_context::current();
>> | ^~~~~~~~~~~~~~
>> 0x76ac28a45caf ???
>> ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
>> 0x591f827efa4b name_lookup::search_namespace_only(tree_node*)
>> ../../gcc/cp/name-lookup.cc:921
>> 0x591f827efc02 name_lookup::search_namespace(tree_node*)
>> ../../gcc/cp/name-lookup.cc:1014
>> 0x591f827efd82 name_lookup::search_namespace(tree_node*)
>> ../../gcc/cp/name-lookup.cc:1009
>> 0x591f827efd82 name_lookup::search_qualified(tree_node*, bool)
>> ../../gcc/cp/name-lookup.cc:1075
>> 0x591f827f2a85 qualified_namespace_lookup
>> ../../gcc/cp/name-lookup.cc:7750
>> 0x591f827f3b8e lookup_qualified_name(tree_node*, tree_node*, LOOK_want, bool)
>> ../../gcc/cp/name-lookup.cc:7709
>> 0x591f82805f16 cp_parser_lookup_name
>> ../../gcc/cp/parser.cc:35403
>> 0x591f8284d8cf cp_parser_class_name
>> ../../gcc/cp/parser.cc:29572
>> 0x591f8283682e cp_parser_qualifying_entity
>> ../../gcc/cp/parser.cc:8308
>> 0x591f8283682e cp_parser_nested_name_specifier_opt
>> ../../gcc/cp/parser.cc:7976
>> 0x591f82831241 cp_parser_simple_type_specifier
>> ../../gcc/cp/parser.cc:22843
>> 0x591f828328ba cp_parser_postfix_expression
>> ../../gcc/cp/parser.cc:8813
>> 0x591f8282f1ae cp_parser_unary_expression
>> ../../gcc/cp/parser.cc:10616
>> 0x591f82811e39 cp_parser_cast_expression
>> ../../gcc/cp/parser.cc:11531
>> 0x591f82812ef3 cp_parser_binary_expression
>> ../../gcc/cp/parser.cc:11634
>> 0x591f82813bfe cp_parser_assignment_expression
>> ../../gcc/cp/parser.cc:11987
>> 0x591f82819ad0 cp_parser_constant_expression
>> ../../gcc/cp/parser.cc:12307
>> 0x591f82819c4c cp_parser_initializer_clause
>> ../../gcc/cp/parser.cc:29059
>> 0x591f8281e908 cp_parser_initializer
>> ../../gcc/cp/parser.cc:28998
>>
>>>
>>>> With debug, the std::meta::info cannot find original type (this
>>>> is a builtin type with -freflection), so add a DECL_ORIGINAL_TYPE
>>>> check.
>>>>
>>
---------------------8<-------------------------
Some ICE will occur when reflection codes compile without
-freflection but the std module built with -freflection.
So the module dialect should include reflection.
gcc/cp/ChangeLog:
* module.cc(module_state_config::get_dialect): Add reflection
dialect.
---
gcc/cp/module.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 02e53ef3969..f7d18420660 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -17247,6 +17247,7 @@ module_state_config::get_dialect ()
? "/coroutines" : ""),
flag_module_implicit_inline ? "/implicit-inline" : "",
flag_contracts ? "/contracts" : "",
+ flag_reflection ? "/reflection" : "",
NULL);
return dialect;
--
2.53.0