https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114275
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- PR105320 seems similar. Another maybe related testcase: $ cat testcase.C export module M; template<class> struct A { template<class> friend struct B; }; A<int> a; template<class> struct B { }; $ cat testcase.C | g++ -fmodules-ts -x c++ - <stdin>:6:27: error: cannot declare ‘struct B< <template-parameter-1-1> >’ in a different module <stdin>:3:34: note: declared here <stdin>:1:8: warning: not writing module ‘M’ due to errors