https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112355
Bug ID: 112355 Summary: Internal compiler error when exporting using declaration of function template Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davidfromonline at gmail dot com Target Milestone: --- The following mostly valid code: ```cxx module; namespace n { template<typename T> void f() { } } export module m; export using n::f; ``` causes gcc to crash with ```console <source>:3:1: error: global module fragment contents must be from preprocessor inclusion 3 | namespace n { | ^~~~~~~~~ <source>:13:17: internal compiler error: tree check: expected none of template_decl, have template_decl in do_nonmember_using_decl, at cp/name-lookup.cc:4853 13 | export using n::f; | ^ 0x8fbb6e tree_not_check_failed(tree_node const*, char const*, int, char const*, ...) gcc/source/gcc/tree.cc:8986 0x76f1d4 tree_not_check(tree_node*, char const*, int, char const*, tree_code) gcc/source/gcc/tree.h:3607 0x76f1d4 do_nonmember_using_decl gcc/source/gcc/cp/name-lookup.cc:4853 0xb63549 finish_nonmember_using_decl(tree_node*, tree_node*) gcc/source/gcc/cp/name-lookup.cc:6297 0xb6d974 finish_using_decl gcc/source/gcc/cp/parser.cc:21908 0xbb482f cp_parser_using_declaration gcc/source/gcc/cp/parser.cc:22072 0xbc8653 cp_parser_declaration gcc/source/gcc/cp/parser.cc:15335 0xbc85d4 cp_parser_module_export gcc/source/gcc/cp/parser.cc:15080 0xbc85d4 cp_parser_declaration gcc/source/gcc/cp/parser.cc:15276 0xbc908a cp_parser_toplevel_declaration gcc/source/gcc/cp/parser.cc:15356 0xbc908a cp_parser_translation_unit gcc/source/gcc/cp/parser.cc:5218 0xbc908a c_parse_file() gcc/source/gcc/cp/parser.cc:50627 0xd0f8e1 c_common_parse_file() gcc/source/gcc/c-family/c-opts.cc:1278 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. Compiler returned: 1 ``` See it live: http://desktop:10240/z/nj5q1b (the crash still exists if the global module fragment comes from an #include, I just made it this way to have a single-file reproduction)