https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107191
Bug ID: 107191 Summary: [modules] ICE when importing module partition (internal compiler error: in tree_node, at cp/module.cc:9061) Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tortoise_74 at yahoo dot co.uk Target Milestone: --- Created attachment 53681 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53681&action=edit Sample code to reproduce the above I have been trying to create a module composed of 2 partitions one of which imports the other. This gives me the error as below: ``` [ 25%] Building CXX object CMakeFiles/gccice.dir/Foo.cpp.o /usr/bin/c++ -fmodules-ts -std=gnu++20 -MD -MT CMakeFiles/gccice.dir/Foo.cpp.o -MF CMakeFiles/gccice.dir/Foo.cpp.o.d -o CMakeFiles/gccice.dir/Foo.cpp.o -c /home/brucea/projects/jobs/gccice/Foo.cpp /home/brucea/projects/jobs/gccice/Foo.cpp:2:8: internal compiler error: in tree_node, at cp/module.cc:9061 2 | export module Foo; | ^~~~~~ 0x7fe43f807d8f __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x7fe43f807e3f __libc_start_main_impl ../csu/libc-start.c:392 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions. make[2]: *** [CMakeFiles/gccice.dir/build.make:76: CMakeFiles/gccice.dir/Foo.cpp.o] Error 1 make[2]: Leaving directory '/home/brucea/projects/jobs/gccice/target' make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/gccice.dir/all] Error 2 make[1]: Leaving directory '/home/brucea/projects/jobs/gccice/target' ``` I thought this might be the same as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99769 The line number is different but I am using the ubuntu version of gcc which might have small differences: > gcc --version gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0 In trying to create a reproducer I have encountered different errors: ``` /tmp/codetest/Foo.cpp:2:8: internal compiler error: in tree_node, at cp/module.cc:9061 2 | export module Foo; | ^~~~~~ 0xe3223b internal_error(char const*, ...) ???:0 0xe28d63 fancy_abort(char const*, int, char const*) ???:0 0x9dd5e6 trees_out::tree_node(tree_node*) ???:0 0x9ddbdf trees_out::core_vals(tree_node*) ???:0 0x9de4ba trees_out::tree_node_vals(tree_node*) ???:0 0x9df707 trees_out::tree_value(tree_node*) ???:0 0x9dd60d trees_out::tree_node(tree_node*) ???:0 0x9ddbdf trees_out::core_vals(tree_node*) ???:0 0x9de4ba trees_out::tree_node_vals(tree_node*) ???:0 0x9df707 trees_out::tree_value(tree_node*) ???:0 0x9dd60d trees_out::tree_node(tree_node*) ???:0 0x9ddbdf trees_out::core_vals(tree_node*) ???:0 0x9de4ba trees_out::tree_node_vals(tree_node*) ???:0 0x9df707 trees_out::tree_value(tree_node*) ???:0 0x9dd60d trees_out::tree_node(tree_node*) ???:0 0x9ddbdf trees_out::core_vals(tree_node*) ???:0 0x9de4ba trees_out::tree_node_vals(tree_node*) ???:0 0x9df707 trees_out::tree_value(tree_node*) ???:0 0x9dd60d trees_out::tree_node(tree_node*) ???:0 0x9ddbdf trees_out::core_vals(tree_node*) ???:0 Please submit a full bug report, ``` And by just adding #include <string>: ``` 50%] Building CXX object CMakeFiles/gccice.dir/Snafu.cpp.o /usr/bin/c++ -fmodules-ts -std=gnu++20 -MD -MT CMakeFiles/gccice.dir/Snafu.cpp.o -MF CMakeFiles/gccice.dir/Snafu.cpp.o.d -o CMakeFiles/gccice.dir/Snafu.cpp.o -c /tmp/codetest/Snafu.cpp In file included from /usr/include/c++/11/bits/locale_classes.h:857, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /tmp/codetest/Bar.cpp:7, of module Foo:Bar, imported at /tmp/codetest/Snafu.cpp:9: /usr/include/c++/11/bits/locale_classes.tcc: In instantiation of 'const _Facet& std::use_facet(const std::locale&) [with _Facet = std::__cxx11::numpunct<char>]': /usr/include/c++/11/bits/locale_facets.tcc:80:66: required from 'void std::__numpunct_cache@Foo:Bar<_CharT>::_M_cache(const std::locale&) [with _CharT = char]' /usr/include/c++/11/bits/locale_facets.tcc:63:18: required from 'const std::__numpunct_cache@Foo:Bar<_CharT>* std::__use_cache@Foo:Bar<std::__numpunct_cache@Foo:Bar<_CharT> >::operator()(const std::locale&) const [with _CharT = char]' /usr/include/c++/11/bits/locale_facets.tcc:384:33: required from '_InIter std::num_get<_CharT, _InIter>::_M_extract_int(_InIter, _InIter, std::ios_base&, std::ios_base::iostate&, _ValueT&) const [with _ValueT = long int; _CharT = char; _InIter = std::istreambuf_iterator<char, std::char_traits<char> >; std::ios_base::iostate = std::ios_base::iostate]' /usr/include/c++/11/bits/locale_facets.h:2220:30: required from 'std::num_get<_CharT, _InIter>::iter_type std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, long int&) const [with _CharT = char; _InIter = std::istreambuf_iterator<char, std::char_traits<char> >; std::num_get<_CharT, _InIter>::iter_type = std::istreambuf_iterator<char, std::char_traits<char> >; std::ios_base::iostate = std::ios_base::iostate]' /usr/include/c++/11/bits/locale_facets.h:2218:7: required from here /usr/include/c++/11/bits/locale_classes.tcc:135:40: internal compiler error: in tsubst_copy, at cp/pt.c:16663 135 | const locale::facet** __facets = __loc._M_impl->_M_facets; | ^~~~~ 0xe3223b internal_error(char const*, ...) ???:0 0xe28d63 fancy_abort(char const*, int, char const*) ???:0 0x10ddc30 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ???:0 0x10de120 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ???:0 0x10de00e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ???:0 0x10de843 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ???:0 0x10de00e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ???:0 0x11709a7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ???:0 0x1170ced tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ???:0 0x1170a93 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ???:0 0x1170a05 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ???:0 0x122bbfa instantiate_decl(tree_node*, bool, bool) ???:0 0xfa8a00 instantiate_pending_templates(int) ???:0 0xfa4663 c_parse_final_cleanups() ???:0 Please submit a full bug report, ```