https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99170
Bug ID: 99170 Summary: [modules] ICE in get_merge_kind with std::string NSDMI Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: remi.galanalfonso at gmail dot com Target Milestone: --- Created attachment 50223 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50223&action=edit preprocessed file Hello, I ran into the following ICE when testing modules a bit, it doesn't look like any currently open module bug (reproduced here with a recent trunk, commit f86e187e12d). The reproducer is as follows: $ cat test_modules.cpp export module test; import <string>; export class A { std::string str{"ayyy"}; }; The <string> header unit was compiled with the following: $ g++ -std=c++20 -fmodules-ts -x c++-system-header string And the command line used and result are the following (along with -v for information): $ g++ -v -save-temps -std=c++20 -fmodules-ts -c test_modules.cpp Using built-in specs. COLLECT_GCC=g++ Target: x86_64-pc-linux-gnu Configured with: ./configure --prefix=/home/remi/Projects/gcc/build-install --disable-multilib : (reconfigured) ./configure --prefix=/home/remi/Projects/gcc/build-install --disable-multilib : (reconfigured) ./configure --prefix=/home/remi/Projects/gcc/build-install --disable-multilib CC=gcc-9 CXX=g++-9 --enable-languages=c,c++,fortran,lto,objc --no-create --no-recursion Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20210219 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-fmodules-ts' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /home/remi/Projects/gcc/build-install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE test_modules.cpp -mtune=generic -march=x86-64 -std=c++20 -fmodules-ts -fpch-preprocess -o test_modules.ii ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0 /home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-pc-linux-gnu /home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward /home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include /usr/local/include /home/remi/Projects/gcc/build-install/include /home/remi/Projects/gcc/build-install/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-fmodules-ts' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /home/remi/Projects/gcc/build-install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/cc1plus -fpreprocessed test_modules.ii -quiet -dumpbase test_modules.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++20 -version -fmodules-ts -o test_modules.s GNU C++20 (GCC) version 11.0.0 20210219 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.0.0 20210218 (experimental), GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version none GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C++20 (GCC) version 11.0.0 20210219 (experimental) (x86_64-pc-linux-gnu) compiled by GNU C version 11.0.0 20210218 (experimental), GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version none GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 8e9853a7486525ef35ca23365b38ea4d test_modules.cpp:1:9: internal compiler error: in get_merge_kind, at cp/module.cc:10158 1 | export module test; | ^~~~~~ 0x699387 trees_out::get_merge_kind(tree_node*, depset*) ../.././gcc/cp/module.cc:10158 0xa13f63 trees_out::decl_value(tree_node*, depset*) ../.././gcc/cp/module.cc:7618 0xa14ebb trees_out::decl_node(tree_node*, walk_kind) ../.././gcc/cp/module.cc:8613 0xa15eb2 trees_out::tree_node(tree_node*) ../.././gcc/cp/module.cc:9168 0xa1b813 module_state::write_pendings(elf_out*, vec<depset*, va_heap, vl_ptr>, depset::hash&, unsigned int, unsigned int*) ../.././gcc/cp/module.cc:15403 0xa1d050 module_state::write(elf_out*, cpp_reader*) ../.././gcc/cp/module.cc:17748 0xa1d71c finish_module_processing(cpp_reader*) ../.././gcc/cp/module.cc:19787 0x9b170b c_parse_final_cleanups() ../.././gcc/cp/decl2.c:5175 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. The ICE disappears when removing the NSDMI, or when calling the default constructor instead in the NSDMI. I have attached the .ii file as advised in https://gcc.gnu.org/bugs/, even though it doesn't look too interesting in this particular case.