https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118846
Bug ID: 118846 Summary: [modules] Unbound template arguments considered TU-local Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Blocks: 103524 Target Milestone: --- Consider the following snippets: export module A; template <int> struct integral_constant; template <template <class> class> constexpr int cx_count_if() { return 0; } template <template <class> class P> struct mp_count_if_impl { using type = integral_constant<cx_count_if<P>()>; }; and export module B; template <template <class> class> struct consume; template <class P> struct use { using type = consume<P::template fn>; }; These cases complain about 'P' and 'P::template fn' being TU-local, respectively, which doesn't really make sense for template parameters. 'g++ -fmodules -S a.cpp': a.cpp:5:9: error: ‘template<template<class> class P> using mp_count_if_impl<P>::type = integral_constant<cx_count_if<P>()>’ exposes TU-local entity ‘struct integral_constant<cx_count_if<P>()>’ 5 | using type = integral_constant<cx_count_if<P>()>; | ^~~~ a.cpp:2:23: note: ‘struct integral_constant<cx_count_if<P>()>’ declared with internal linkage 2 | template <int> struct integral_constant; | ^~~~~~~~~~~~~~~~~ 'g++ -fmodules -S b.cpp': b.cpp:4:9: error: ‘template<class P> using use<P>::type = consume<P::template fn>’ exposes TU-local entity ‘struct consume<P::template fn>’ 4 | using type = consume<P::template fn>; | ^~~~ b.cpp:2:42: note: ‘struct consume<P::template fn>’ has TU-local template argument ‘P::template fn’ 2 | template <template <class> class> struct consume; | ^~~~~~~ b.cpp:4:36: note: ‘P::template fn’ declared with internal linkage 4 | using type = consume<P::template fn>; | ^~ It's also worth noting that with '-fconcepts', having any other declaration with a constraint (e.g. adding 'requires true' to 'consume') will cause a segfault during diagnostic printing for B. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524 [Bug 103524] [meta-bug] modules issue