-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Linker failure for std::visit with a templated lambda using a forward declared templated function #115731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Might be related to #57561 |
@llvm/issue-subscribers-clang-frontend Author: None (StefanPaulet)
```cpp
#include <type_traits>
#include <variant>
using MyType = std::variant<double, int>; template <typename T> auto bar(MyType const& v) { template <typename T> int main() {
|
Adding diagnostics b/c it helps w/ searchability for folks looking for the same issue. |
Managed to reduce the code and remove all includes: Also found that when the lambda has a deduced return type or when it is not locally declared inside the function everything works: The problem seems to be that a locally declared lambda without a deduced return type gets eagerly instantiated and that it recursively tries to instantiate |
I would like to try and tackle this issue. However, I'm having a hard time understanding what the expected behaviour should be. |
The symptom then looks like a duplicate of #35052 to me. I tried to instantiate the local lambda eagerly so the constant evaluation would find a definition before it evaluates anything, but changing that behavior turns out to break DeduceReturnType for one case, so it gets reverted, unfortunately. |
Yep, they seem to be related. Although one is an issue of generic lambdas being too eagerly instantiated, and the other of a generic lambda not getting instantiated for constant evaluation (I think). |
Looks fixed in clang trunk but I have no idea why: https://godbolt.org/z/o4c8xfxYM |
|
Uh oh!
There was an error while loading. Please reload this page.
https://godbolt.org/z/n54f19hn5
It seems that only the declarations get generated for
foo
, but no definitions. However, iffoo
is no longer forward declared, everything works: https://godbolt.org/z/c1WY647af.Diagnostics:
The text was updated successfully, but these errors were encountered: