llvm / llvm/llvm-project

Modules: reachable template class is deemed incomplete at the point of instantiation if defined in a different partition

Open
#164,466 5 comments 0 reactions 1 assignee Claimed by @ChuanqiXu9 View on GitHub
clang:modules
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.