https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122908
--- Comment #9 from Bernardo Negri <b.gomes.negri at gmail dot com> --- (In reply to Nathaniel Shead from comment #6) > What makes you say that? Within a module interface unit, only in a private > module fragment is an exposure allowed, by > https://eel.is/c++draft/basic.link#17. Confusion about the difference between the private module fragment and the global module fragment. Thank you for clarifying, I was not reading the spec correctly. However, this just makes me more confused about the intended use for global module fragments, since it is possible to violate exposure rules by merely #include ing a header. Consider a 3rd party library: // class.h template <typename T> static size_t getSize(const std::vector<T> &list) { return list.size(); } template <typename T> class Class { void processList(std::vector<T> list) { getSize(list); } } This library is fine to use with the traditional .cpp plus header files structure (though it is deprecated), but if you try to use it in a project with modules, just #include ing it on the GMF is an error according to the standard. The only solution I know is with header units, which are not well supported by build systems. Are there any other ways? One example of where this kind of stuff is used constantly is in Qt code, which means trying to do anything Qt-related with modules will lead to a ton of errors unless you treat every Qt class as TU-local to avoid marking them as decl-reachable. And even then you'll get errors just from instantiating a template. You are right, the program I attached is technically incorrect according to the standard, because Class::testFn (not TU-local) names internalLink (TU-local). Everything else is necessary for GCC to consider Class decl-reachable. (In reply to Nathaniel Shead from comment #8) > Thanks for your time and your bug report, it's greatly appreciated. Let me > know if there's anything else I can try and clarify. It is I who should be thanking you for explaining to a newbie these complex C++ concepts. All your feedback is also appreciated.
