https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116401
Bug ID: 116401
Summary: [modules] Header units can contain definitions of
non-inline decls with external linkage
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: ---
https://eel.is/c++draft/module.import#6 says:
> A header unit shall not contain a definition of a non-inline function or
> variable whose name has external linkage.
However we currently accept the following code:
// header.hpp
int foo() { return 5; }
// main.cpp
import "header.hpp";
int main() {
return foo();
}
Doing 'g++ -fmodules-ts header.hpp main.cpp' builds the header unit
successfully but then fails to link with "undefined reference to 'foo'" which
is fairly unhelpful.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
[Bug 103524] [meta-bug] modules issue