Modules: reachable template class is deemed incomplete at the point of instantiation if defined in a different partition
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
p1.cpp
``` cpp
export module m:p1;
template
class Incognita;
export template
class Variable
{
public:
Incognita foo() const { return {*this}; }
};
```
p2.cpp
```cpp
export module m:p2;
import :p1;
template
class Incognita
{
public:
Incognita(const Variable &) {}
};
```
m.cpp
```cpp
export module m;
export import :p1;
export import :p2;
```
example.cpp
```cpp
import m;
int main()
{
Variable x;
auto bar = x.foo();
}
```
```
example.cpp:7:14: error: implicit instantiation of undefined template 'Incognita'
7 | auto bar = x.foo();
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
p1.cpp:11:16: error: implicit instantiation of undefined template 'Incognita'
11 | Incognita foo() const { return {*this}; }
| ^
example.cpp:7:14: note: in instantiation of member function 'Variable::foo' requested here
7 | auto bar = x.foo();
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
p1.cpp:11:37: error: implicit instantiation of undefined template 'Incognita'
11 | Incognita foo() const { return {*this}; }
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
```
https://godbolt.org/z/naq543aqW
Contributor guide
Assessment
This issue has not been assessed yet.