| Issue |
86958
|
| Summary |
Clang fails to export template specialization in C++20 if it's used in the same TU
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
aganea
|
When building with `clang-cl.exe`, the following wouldn't export `foo<0>`. This works with MSVC `cl.exe`.
```
// a.cpp
struct A {
template <bool T > static bool __declspec(dllexport) foo();
//template<> bool __declspec(dllexport) foo<false>();
};
template <typename T>
T b() { return A::foo<false>() ? 1 : 0; }
template<> bool __declspec(dllexport) A::foo<false>() { return false; }
int main() {
return b<int>();
}
```
No symbols are exported:
```
> clang-cl.exe a.cpp /c /std:c++20
> dumpbin /all a.obj | grep EXPORT
(empty stdout)
```
Removing `/std:c++20` from the cmd-line would export the specialization `foo<0>`.
Removing the commented-out specialization forward decl in the struct would export the specialization.
Moving the specialization before `b()` works too:
```
// a.cpp
struct A {
template <bool T > static bool __declspec(dllexport) foo();
};
template<> bool __declspec(dllexport) A::foo<false>() { return false; }
template <typename T>
T b() { return A::foo<false>() ? 1 : 0; }
int main() {
return b<int>();
}
```
In the first example above, if `main()` doesn't call `b()` the specialization would be exported as well.
+@zmodem Since you've worked in this area in the past.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs