https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124920
Bug ID: 124920
Summary: Using “-freflection” Together with “import std” and
“#include” Causes an ICE
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: printfne at gmail dot com
Target Milestone: ---
Including any header will trigger this issue; <meta> is just an example.
Removing any one of #include, import, or -freflection eliminates the ICE
// static_serialize.cppm
module;
#include <meta>
export module static_serialize;
import std;
export template <typename T>
void serialize(T& obj) { }
// command
// Whether std.cc is compiled or not does not affect the triggering of this
ICE.
g++-trunk -std=c++26 -fmodules -c -fsearch-include-path bits/std.cc
g++-trunk -std=c++26 -fmodules -c -freflection ./static_serialize.cppm
// gcc version
g++ (GCC) 16.0.1 20260418 (experimental)
// error message
In file included from /usr/include/sys/types.h:227,
from /usr/include/stdlib.h:518,
from /home/hexne/gcc-trunk/include/c++/16.0.1/cstdlib:83,
from
/home/hexne/gcc-trunk/include/c++/16.0.1/x86_64-pc-linux-gnu/bits/stdc++.h:39,
from /home/hexne/gcc-trunk/include/c++/16.0.1/bits/std.cc:26,
of module std, imported at ./static_serialize.cppm:4:
/usr/include/bits/pthreadtypes.h:72:3: error: conflicting type for imported
declaration 'typedef union pthread_mutex_t pthread_mutex_t'
72 | } pthread_mutex_t;
| ^~~~~~~~~~~~~~~
In file included from /usr/include/sys/types.h:227,
from /usr/include/stdlib.h:518,
from /home/hexne/gcc-trunk/include/c++/16.0.1/cstdlib:83,
from
/home/hexne/gcc-trunk/include/c++/16.0.1/bits/stl_algo.h:71,
from /home/hexne/gcc-trunk/include/c++/16.0.1/algorithm:63,
from ./static_serialize.cppm:2:
/usr/include/bits/pthreadtypes.h:72:3: note: existing declaration 'typedef
union pthread_mutex_t pthread_mutex_t'
72 | } pthread_mutex_t;
| ^~~~~~~~~~~~~~~
In file included from /home/hexne/gcc-trunk/include/c++/16.0.1/optional:52,
from
/home/hexne/gcc-trunk/include/c++/16.0.1/bits/ranges_algo.h:37,
from /home/hexne/gcc-trunk/include/c++/16.0.1/algorithm:65:
/home/hexne/gcc-trunk/include/c++/16.0.1/bits/functional_hash.h:258:53:
internal compiler error: in read_definition, at cp/module.cc:14153
258 | return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
0x2b13fdf internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0xb58721 fancy_abort(char const*, int, char const*)
../../gcc/diagnostics/context.cc:1813
0x854c1f read_definition
../../gcc/cp/module.cc:14153
0xd0ffa1 module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17711
0xd10acf module_state::load_section(unsigned int, binding_slot*)
../../gcc/cp/module.cc:21536
0xd10b86 module_state::lazy_load(unsigned int, binding_slot*)
../../gcc/cp/module.cc:22565
0xd08b05 tree_node
../../gcc/cp/module.cc:11045
0xd0fc3b module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17539
0xd10acf module_state::load_section(unsigned int, binding_slot*)
../../gcc/cp/module.cc:21536
0xd10b86 module_state::lazy_load(unsigned int, binding_slot*)
../../gcc/cp/module.cc:22565
0xd08b05 tree_node
../../gcc/cp/module.cc:11045
0xd0fc3b module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17539
0xd10acf module_state::load_section(unsigned int, binding_slot*)
../../gcc/cp/module.cc:21536
0xd10b86 module_state::lazy_load(unsigned int, binding_slot*)
../../gcc/cp/module.cc:22565
0xd08b05 tree_node
../../gcc/cp/module.cc:11045
0xd0fc3b module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17539
0xd10acf module_state::load_section(unsigned int, binding_slot*)
../../gcc/cp/module.cc:21536
0xd10b86 module_state::lazy_load(unsigned int, binding_slot*)
../../gcc/cp/module.cc:22565
0xd08b05 tree_node
../../gcc/cp/module.cc:11045
0xd0fc3b module_state::read_cluster(unsigned int)
../../gcc/cp/module.cc:17539
/home/hexne/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet
-D_GNU_SOURCE ./static_serialize.cppm -quiet -dumpbase static_serialize.cppm
-dumpbase-ext .cppm -mtune=generic -march=x86-64 -std=c++26 -fmodules
-freflection -o /tmp/ccK2AgVc.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.