https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119763
Bug ID: 119763
Summary: [modules] Declarations in extern "C++" incorrectly
treated as attached to named module
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
Target Milestone: ---
Consider:
// main.cpp
export module M;
extern "C++" {
static int internal() { return 123; }
export struct S {
int foo() { return internal(); }
};
}
$ g++ -fmodules -S main.cpp
main.cpp:5:9: error: 'int S::foo()' exposes TU-local entity 'int internal()'
5 | int foo() { return internal(); }
| ^~~
main.cpp:3:14: note: 'int internal()' declared with internal linkage
3 | static int internal() { return 123; }
| ^~~~~~~~
But this is wrong: by https://eel.is/c++draft/module.unit#7.2.2, 'S' is
attached to the global module, and so by https://eel.is/c++draft/class.mfct#1
it should be declared 'inline', which means that this is not an exposure.