| Issue |
115731
|
| Summary |
[clang] Linker failure for std::visit with a templated lambda using a forward declared templated function
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
StefanPaulet
|
```cpp
#include <type_traits>
#include <variant>
using MyType = std::variant<double, int>;
template <typename T>
auto foo(T&& arg) -> std::remove_cvref_t<T>;
auto bar(MyType const& v) {
auto callable = []<typename Arg>(Arg&& arg) -> MyType {
return foo(std::forward<Arg>(arg));
};
return std::visit(callable, v);
}
template <typename T>
auto foo(T&& arg) -> std::remove_cvref_t<T> {
return arg;
}
int main() {
MyType b {5.3};
bar(b);
}
```
https://godbolt.org/z/n54f19hn5
It seems that only the declarations get generated for `foo`, but no definitions. However, if `foo` is no longer forward declared, everything works: https://godbolt.org/z/c1WY647af.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs