https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127371
Bug ID: 127371
Summary: [modules][reflection] ICE in walk_namespace_bindings
when namespaces are supplied via partitions
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mail at tobiasliese dot me
Target Milestone: ---
Created attachment 65578
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65578&action=edit
ccebJnGx.out
Given the following structure:
m.cppm:
```cpp
export module m:p;
export namespace demo { inline int x; }
```
primary.cppm:
```cpp
export module m;
export import :p;
```
use.cppm:
```cpp
module m;
import std;
import :p;
constexpr auto n = std::meta::members_of(^^demo,
std::meta::access_context::current()).size();
```
and compiler invokation using:
```sh
g++ -std=c++26 -freflection -fmodules -x c++ -c m.cppm
g++ -std=c++26 -freflection -fmodules -x c++ -c primary.cppm
g++ -std=c++26 -freflection -fmodules --compile-std-module use.cpp
```
The compiler crashes with the following crash report:
use.cpp:4:41: internal compiler error: in add, at hash-set.h:64
4 | constexpr auto n = std::meta::members_of(^^demo,
std::meta::access_context::current()).size();
|
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x2e5ce5f internal_error(char const*, ...)
/home/tobias/gcc_build/../gcc/gcc/diagnostic-global-context.cc:787
0xbd2fa7 fancy_abort(char const*, int, char const*)
/home/tobias/gcc_build/../gcc/gcc/diagnostics/context.cc:1813
0xc3305f hash_set<tree_node*, false, default_hash_traits<tree_node*>
>::add(tree_node* const&)
/home/tobias/gcc_build/../gcc/gcc/hash-set.h:64
0xc3305f hash_set<tree_node*, false, default_hash_traits<tree_node*>
>::add(tree_node* const&)
/home/tobias/gcc_build/../gcc/gcc/hash-set.h:56
0xdc0a22 operator()
/home/tobias/gcc_build/../gcc/gcc/cp/name-lookup.cc:4375
0xdc0a22 walk_namespace_bindings(tree_node*, void (*)(tree_node*, void*),
void*)
/home/tobias/gcc_build/../gcc/gcc/cp/name-lookup.cc:4446
0xed1c65 namespace_members_of
/home/tobias/gcc_build/../gcc/gcc/cp/reflect.cc:7064
0xed1c65 eval_members_of
/home/tobias/gcc_build/../gcc/gcc/cp/reflect.cc:7322
0xed8876 process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
/home/tobias/gcc_build/../gcc/gcc/cp/reflect.cc:8352
0xc3f734 cxx_eval_call_expression
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:4415
0xc43489 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:9806
0xc4615d cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:9943
0xc440b4 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:10233
0xc3fcad cxx_bind_parameters_in_call
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:3272
0xc3fcad cxx_eval_call_expression
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:4635
0xc43489 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:9806
0xc55a21 cxx_eval_outermost_constant_expr
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:11408
0xc600cd maybe_constant_value(tree_node*, tree_node*, mce_value)
/home/tobias/gcc_build/../gcc/gcc/cp/constexpr.cc:11848
0xf629e1 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
/home/tobias/gcc_build/../gcc/gcc/cp/typeck2.cc:1079
0xceb323 check_initializer
/home/tobias/gcc_build/../gcc/gcc/cp/decl.cc:8767
/opt/gcc-17-20260906/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1plus
-quiet -iprefix /opt/gcc-17-20260906/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/
-D_GNU_SOURCE use.cpp -quiet -dumpdir a- -dumpbase use.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -std=c++26 -freflection -fmodules -o
/tmp/ccEMNrGw.s
I tested gcc-17-20260906 and gcc-16.2.1 both are affected.
Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124200 seems to be related, as
the PR that fixed it, introduced walk_namespace_bindings that causes this
crash.