https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113814
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nshead at gcc dot gnu.org
--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
A related-looking issue:
$ cat a.hpp
template <typename T>
struct X {
T* get();
};
struct S;
inline X<S> x;
$ cat b.hpp
struct S { int y = 0; };
$ cat c.cpp
import "a.hpp";
import "b.hpp";
//template struct X<S>; (!!)
int main() {
int b = x.get()->y;
}
$ g++ -std=c++20 -fmodules-ts -S a.hpp b.hpp c.cpp
c.cpp: In function ‘int main()’:
c.cpp:6:18: error: invalid use of incomplete type ‘struct S’
6 | int b = x.get()->y;
| ^~
In module ./a.hpp, imported at c.cpp:1:
a.hpp:6:8: note: forward declaration of ‘struct S’
6 | struct S;
|
Uncommenting the marked line resolves this particular issue by forcing a new
instantiation of X<S>.